Skip to content

Better handle signals in tsc CLI - #4911

Closed
Jake Bailey (jakebailey) wants to merge 1 commit into
mainfrom
jabaile/redo-4592
Closed

Better handle signals in tsc CLI#4911
Jake Bailey (jakebailey) wants to merge 1 commit into
mainfrom
jabaile/redo-4592

Conversation

@jakebailey

@jakebailey Jake Bailey (jakebailey) commented Aug 17, 2026

Copy link
Copy Markdown
Member

@DanielRosenwasser

Copy link
Copy Markdown
Member

Wasn't part of the original intent for handling signals to do something special during profiling?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Restores default OS signal handling for the tsc CLI so SIGINT and SIGTERM terminate immediately.

Changes:

  • Removes CLI signal interception.
  • Uses a background context for compilation; API and LSP handling remain unchanged.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@jakebailey

Copy link
Copy Markdown
Member Author

Yeah.... but the only way that would work is if we profile watch mode. Otherwise we'd just let it go to exit.

I don't think it's worth it for now if it hangs Ctrl+C; we can invent a mode which does cancellation if profiling isn't running or add our own exit hooks (like Go does!). But that's more complicated.

@lukesandberg

Copy link
Copy Markdown

per my testing (see comment: #4592 (comment)) this will cause odd panics if you ctrl-c a watch mode build

here is my attempt at this same idea that avoids the 'all goroutines are blocked' issue

main...lukesandberg:typescript-go:lukesandberg/no_signal_handler_for_compile

@jakebailey

Copy link
Copy Markdown
Member Author

That's plausible, but that platform code would belong in osutil.

@jakebailey

Copy link
Copy Markdown
Member Author

Feel free to open it, I just assumed you wouldn't reply so quickly 😄

@lukesandberg

Copy link
Copy Markdown

I don't have permissions to open PRs anymore

@jakebailey

Copy link
Copy Markdown
Member Author

If you restore the branch in #4592, I can reopen it

@lukesandberg

Copy link
Copy Markdown

dd5868e is on a different branch
you can just cherry pick it if you want it

@jakebailey
Jake Bailey (jakebailey) force-pushed the jabaile/redo-4592 branch 2 times, most recently from 902f44f to 934a059 Compare August 18, 2026 18:19
@jakebailey
Jake Bailey (jakebailey) requested a balanced review from Copilot August 18, 2026 18:34
@jakebailey Jake Bailey (jakebailey) changed the title Stop handling signals in tsc CLI Better handle signals in tsc CLI Aug 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

internal/execute/tsc.go:126

  • This new signal/watch path has no regression coverage. Because this change fixes a process-level interruption bug, add subprocess tests that send SIGINT/SIGTERM and verify normal compilation, watch mode, and profiling terminate promptly without the watch deadlock and that profiling flushes its output before exit.
	if buildCommand.CompilerOptions.Watch.IsTrue() && !profiled && options.WatchContext != nil {
		var stop context.CancelFunc
		ctx, stop = options.WatchContext(ctx)
		defer stop()

@jakebailey Jake Bailey (jakebailey) added the Unmigrated PR This PR was open at the time of the repo move back to TypeScript label Aug 19, 2026
@jakebailey

Copy link
Copy Markdown
Member Author

I'm going to just defer this until after the repo move.

@RyanCavanaugh

Copy link
Copy Markdown
Member

Thank you for contributing to the TypeScript native port!

Development has moved from this repository back to the main microsoft/TypeScript repository. GitHub does not have PR transfer functionality, so we're closing this PR here.

If this change is still relevant, please reopen it as a new pull request in microsoft/TypeScript. We'd appreciate your help carrying the contribution over, and we apologize for the extra work.

See microsoft/typescript-go#4918 for more information about the move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Unmigrated PR This PR was open at the time of the repo move back to TypeScript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsc is not resposive to ctrl-c

5 participants