Skip to content

feat: restart dev server on config changes#27

Open
chenjiahan wants to merge 3 commits into
mainfrom
chenjiahan/feat-watch-rstack-config
Open

feat: restart dev server on config changes#27
chenjiahan wants to merge 3 commits into
mainfrom
chenjiahan/feat-watch-rstack-config

Conversation

@chenjiahan

@chenjiahan chenjiahan commented Jul 11, 2026

Copy link
Copy Markdown
Member

rs dev previously 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's reload-server watch list while preserving user-defined watchers. The integration test follows Rsbuild's reload-config pattern and reuses shared CLI, port, and file polling helpers.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@chenjiahan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fc5d5263-566c-40e7-9535-8df176d89e4c

📥 Commits

Reviewing files that changed from the base of the PR and between 2a8b4cd and a2813d6.

📒 Files selected for processing (10)
  • .gitignore
  • packages/rstack/src/config.ts
  • packages/rstack/src/rsbuildConfig.ts
  • packages/rstack/src/rslibConfig.ts
  • packages/rstack/src/rslintConfig.ts
  • packages/rstack/src/rspressConfig.ts
  • packages/rstack/src/rstestConfig.ts
  • packages/rstack/src/staged.ts
  • packages/rstack/test/config/reload-app-config/index.test.ts
  • packages/rstack/test/config/reload-app-config/src/index.js
📝 Walkthrough

Walkthrough

Rstack 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 rstack.config.ts during development and verifies that output moves from dist to dist-2.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed It clearly summarizes the main change: restarting the dev server when config changes.
Description check ✅ Passed The description is directly aligned with the PR and accurately describes the config reload and test updates.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chenjiahan/feat-watch-rstack-config

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chenjiahan chenjiahan force-pushed the chenjiahan/feat-watch-rstack-config branch from 5c331c2 to 864dab9 Compare July 11, 2026 09:42

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread packages/rstack/src/rsbuildConfig.ts
@chenjiahan chenjiahan force-pushed the chenjiahan/feat-watch-rstack-config branch from 864dab9 to 2a8b4cd Compare July 11, 2026 09:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread packages/rstack/src/rsbuildConfig.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 56fecd5 and 2a8b4cd.

📒 Files selected for processing (8)
  • packages/rstack/src/config.ts
  • packages/rstack/src/rsbuildConfig.ts
  • packages/rstack/test/config/reload-app-config/.gitignore
  • packages/rstack/test/config/reload-app-config/index.test.ts
  • packages/rstack/test/config/reload-app-config/src/index.js
  • packages/rstack/test/helpers/cli.ts
  • packages/rstack/test/helpers/cliTest.ts
  • packages/rstack/test/helpers/utils.ts

Comment thread packages/rstack/test/helpers/cliTest.ts Outdated
Comment on lines +71 to +78
const childProcess = nodeExec(`node ${RSTACK_BIN_PATH} ${command}`, {
...options,
cwd: options.cwd ?? cwd,
env: {
...restEnv,
...options.env,
},
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 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.

Suggested change
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@chenjiahan chenjiahan force-pushed the chenjiahan/feat-watch-rstack-config branch from 5bdbba4 to a2813d6 Compare July 11, 2026 14:24
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