feat: restart dev server on config changes#27
Conversation
|
Warning Review limit reached
Next review available in: 26 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughRstack configuration loading now exposes the loaded config file path and dependencies. Development Rsbuild configuration watches these paths and triggers server reloads when they change. Test helpers now support asynchronous CLI processes, polling, file checks, and random port allocation. A new integration test changes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
5c331c2 to
864dab9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c331c2893
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
864dab9 to
2a8b4cd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a8b4cd9ac
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/rstack/test/helpers/cliTest.ts`:
- Around line 71-78: Replace the nodeExec invocation in the CLI test helper with
child_process.spawn, passing "node" and an argument array containing
RSTACK_BIN_PATH plus the command arguments. Preserve the existing cwd and merged
environment options, and ensure command paths containing spaces are handled
without shell interpolation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d0244cc5-71b1-47eb-955d-dbb35ad963d3
📒 Files selected for processing (8)
packages/rstack/src/config.tspackages/rstack/src/rsbuildConfig.tspackages/rstack/test/config/reload-app-config/.gitignorepackages/rstack/test/config/reload-app-config/index.test.tspackages/rstack/test/config/reload-app-config/src/index.jspackages/rstack/test/helpers/cli.tspackages/rstack/test/helpers/cliTest.tspackages/rstack/test/helpers/utils.ts
| const childProcess = nodeExec(`node ${RSTACK_BIN_PATH} ${command}`, { | ||
| ...options, | ||
| cwd: options.cwd ?? cwd, | ||
| env: { | ||
| ...restEnv, | ||
| ...options.env, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Prefer spawn with argument array over exec with string interpolation.
nodeExec (child_process.exec) runs the command in a shell. If RSTACK_BIN_PATH contains spaces (e.g., a user's home directory with a space), the shell will misparse the command. Using spawn('node', [RSTACK_BIN_PATH, ...command.split(' ')], opts) avoids this and aligns with the static analysis findings (CWE-78).
♻️ Proposed refactor
-import { type ChildProcess, type ExecOptions, exec as nodeExec } from 'node:child_process';
+import { type ChildProcess, type SpawnOptions, spawn } from 'node:child_process'; const execCliAsync: ExecCliAsync = (command, options = {}) => {
const { NODE_ENV: _, ...restEnv } = process.env;
- const childProcess = nodeExec(`node ${RSTACK_BIN_PATH} ${command}`, {
+ const childProcess = spawn('node', [RSTACK_BIN_PATH, ...command.split(' ')], {
...options,
cwd: options.cwd ?? cwd,
env: {
...restEnv,
...options.env,
},
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const childProcess = nodeExec(`node ${RSTACK_BIN_PATH} ${command}`, { | |
| ...options, | |
| cwd: options.cwd ?? cwd, | |
| env: { | |
| ...restEnv, | |
| ...options.env, | |
| }, | |
| }); | |
| const childProcess = spawn('node', [RSTACK_BIN_PATH, ...command.split(' ')], { | |
| ...options, | |
| cwd: options.cwd ?? cwd, | |
| env: { | |
| ...restEnv, | |
| ...options.env, | |
| }, | |
| }); |
🧰 Tools
🪛 ast-grep (0.44.1)
[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { type ChildProcess, type ExecOptions, exec as nodeExec } from 'node:child_process';
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(detect-child-process-typescript)
🪛 OpenGrep (1.23.0)
[ERROR] 71-78: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.
(coderabbit.command-injection.exec-js)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/rstack/test/helpers/cliTest.ts` around lines 71 - 78, Replace the
nodeExec invocation in the CLI test helper with child_process.spawn, passing
"node" and an argument array containing RSTACK_BIN_PATH plus the command
arguments. Preserve the existing cwd and merged environment options, and ensure
command paths containing spaces are handled without shell interpolation.
Source: Linters/SAST tools
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5bdbba40f1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| closes.push(() => { | ||
| childProcess.stdout?.off('data', onData); | ||
| childProcess.stderr?.off('data', onData); | ||
| childProcess.kill(); |
There was a problem hiding this comment.
Kill the spawned CLI process tree during cleanup
When execCliAsync('dev') starts a long-running server, nodeExec runs the command through a shell, so this cleanup kills only that shell process. On POSIX this leaves the node ... rs dev child reparented and still running after the test finishes, which can leak file watchers/ports across the suite; spawn the CLI directly or terminate the whole process group/tree before returning from the fixture.
Useful? React with 👍 / 👎.
5bdbba4 to
a2813d6
Compare
rs devpreviously watched only Rstack's internal Rsbuild bridge, so changes to the actual Rstack config did not restart the server. This PR exposes the loaded config path and relative dependencies, then merges them into Rsbuild'sreload-serverwatch list while preserving user-defined watchers. The integration test follows Rsbuild's reload-config pattern and reuses shared CLI, port, and file polling helpers.