Skip to content

Conversation

@tmm1
Copy link
Contributor

@tmm1 tmm1 commented Dec 19, 2025

I would like to improve #1317, and step one is being able to profile what's currently happening.

Copilot AI review requested due to automatic review settings December 19, 2025 22:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables profiling support for the TypeScript compiler's watch mode by handling --pprofDir with --watch. Previously, profiling would stop immediately when watch mode started its monitoring loop, preventing meaningful profiling data collection during file watching operations.

Key Changes

  • Adds signal handling to gracefully stop profiling on interrupt signals (SIGINT/SIGTERM) when watch mode is active
  • Removes the immediate defer profileSession.Stop() call for watch mode to allow continuous profiling

<-ctx.Done()
profileSession.Stop()
os.Exit(int(tsc.ExitStatusSuccess))
}()
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

When watch mode is disabled, the profiling session is never stopped because the defer profileSession.Stop() was removed. The defer statement should be preserved and only skipped when watch mode is enabled. Consider adding else { defer profileSession.Stop() } after the watch mode block.

Suggested change
}()
}()
} else {
defer profileSession.Stop()

Copilot uses AI. Check for mistakes.
defer stop()
<-ctx.Done()
profileSession.Stop()
os.Exit(int(tsc.ExitStatusSuccess))
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

Calling os.Exit() from a goroutine bypasses deferred cleanup functions in the main goroutine and can lead to incomplete cleanup. Consider using a channel or context cancellation to signal the main goroutine to exit gracefully instead.

Copilot uses AI. Check for mistakes.
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.

1 participant