Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(signals): prefactor #9995

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

chris-olszewski
Copy link
Member

Description

Prefactors:

  • moved signal listening to own crate
  • return signal received to subscribers
  • support streams instead of single futures for signal sources

PR that prefactors the signals code to prepare for:

  • Subscribers getting all signals sent to turbo
  • Additional signal handlers to be sent transparently to children

There are no behavior changes in this PR. I highly suggest reviewing each commit on its own.

Testing Instructions

Existing unit tests.

Quick manual verification that existing SIGINT behavior remains the same:

$ turbo_dev watch build
...
│    Finalizing page optimization  .   Collecting build traces  .
└────>
  × Watch interrupted due to signal

Copy link

vercel bot commented Feb 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-basic-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 3:15pm
examples-designsystem-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 3:15pm
examples-gatsby-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 3:15pm
examples-kitchensink-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 3:15pm
examples-native-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 3:15pm
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 3:15pm
examples-svelte-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 3:15pm
examples-tailwind-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 3:15pm
examples-vite-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 3:15pm

@chris-olszewski chris-olszewski marked this pull request as draft February 18, 2025 14:03
Copy link
Contributor

@NicholasLYang NicholasLYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple questions

edition = "2021"

[dependencies]
futures = "0.3.30"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason we're using a different version for futures instead of the workspace root version?

Comment on lines +151 to +154
#[cfg(windows)]
const DEFAULT_SIGNAL: Signal = Signal::CtrlC;
#[cfg(not(windows))]
const DEFAULT_SIGNAL: Signal = Signal::Interrupt;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but we could do and avoid the conditional compilation

Suggested change
#[cfg(windows)]
const DEFAULT_SIGNAL: Signal = Signal::CtrlC;
#[cfg(not(windows))]
const DEFAULT_SIGNAL: Signal = Signal::Interrupt;
const DEFAULT_SIGNAL: Signal = if cfg!(windows) { Signal::CtrlC } else {Signal::Interrupt };


#[cfg(windows)]
/// A listener for Windows Console Ctrl-C events
pub fn get_signal() -> Result<impl Stream<Item = Option<Signal>>, std::io::Error> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor detail, but maybe we should make this a custom error type so we can annotate the run::Error type with #[from] and avoid having to use map_err when calling this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants