Repository navigation
fix(react): close the TypeScript watch program when the dev server closes - #595
Merged
Merged
Conversation
…oses With `reactDocgen: 'react-docgen-typescript'` the dev server starts a TypeScript watch program, but its cleanup was registered only on `onCloseBuild`. Rsbuild fires that hook for build instances only; closing a dev server fires `onCloseDevServer`, so the watch program and all of its file watchers stayed open until the process exited. Register one idempotent close handler on both hooks, matching the Vite plugin's `closeBundle`, which runs after a build and on dev server close. Part of #592
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With
reactDocgen: 'react-docgen-typescript', the dev server starts a TypeScript watch program whose cleanup was registered only ononCloseBuild. Rsbuild fires that hook for build instances only; closing a dev server firesonCloseDevServer(@rsbuild/coredist/m.js:closeServerResources→onCloseDevServer.callBatch(), whileonCloseBuild.callBatch()is reached only frombuild()). So in dev modecloseWatch()never ran and everyts.sys.watchFile/watchDirectorywatcher stayed open until the process exited.This registers one close handler on both hooks, matching the vendored Vite plugin's
closeBundle, which runs after a build and on dev server close.closeWatchis typedCloseWatch | undefinedand called with?.()so a close hook that fires beforemodifyRsbuildConfigran no longer throws.Part of #592 (first checkbox).
Impact
Not observable with the
storybook devCLI: every bail path is followed byprocess.exit, and the OS releases the watchers. It matters for programmatic dev-mode callers that catch a startup failure and keep the process alive, where the open watchers kept the event loop running and leaked file descriptors.Test
__tests__/index.test.ts— thefile watchershelper now wraps thets.syswatchers and reports how many are still open after a given close hook fires. New case:closes every file watcher when the dev server closes. Without theonCloseDevServerregistration it fails withexpected 581 to be +0; with it, 13/13 pass.pnpm checkpasses. No change to.agents/skills/storybook-check/manifest.json:index.tsis inlocalOnlyFiles(vendored from the Vite plugin, not ported from upstream Storybook).