Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughRefactors the dev-worker abstraction to an EnvRunner across the codebase: renames types and classes, replaces createDevWorker with getEnvRunner and cached _envRunner, updates Vite/dev runtime entry to node-runner, adjusts message/upgrade APIs, and adds shutdown + JSON error handling in the runtime. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
Comment |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/types/runner.ts (1)
27-34: Consider makingupgradeoptional in the interface.In
src/build/vite/dev.ts(line 135),upgradeis called with optional chaining (upgrade?.()), suggesting not all runners may implement this method. However, the interface declares it as required.export interface EnvRunner extends WorkerHooks, RunnerRPCHooks { readonly ready: boolean; readonly closed: boolean; fetch: FetchHandler; - upgrade: UpgradeHandler; + upgrade?: UpgradeHandler; close(): Promise<void>; }src/build/vite/plugin.ts (1)
16-19: Env runner integration in setupNitroContext is sound; minor comment typoThe new
getEnvRunner(ctx)import, dev-only warm-up,ctx.nitro.fetch = (req) => getEnvRunner(ctx).fetch(req), and close hook that callsctx._envRunner.close()together provide a coherent lifecycle for the shared env runner without obvious behavioral regressions. Only nit: the comment// Warm uop env runner for devhas a small typo (“uop” → “up”).- // Warm uop env runner for dev + // Warm up env runner for devAlso applies to: 435-453
src/dev/server.ts (1)
74-92: Ensure all runners are actually closed on reload/dev:errorBecause
onCloseremoves a worker fromthis.#workers, iterating withfor (const worker of this.#workers)while callingworker.close()can skip elements when the array is mutated during iteration, leaving some old workers alive (resource leak and stray RPC targets). Iterating over a shallow copy avoids this.nitro.hooks.hook("dev:error", (cause: unknown) => { this.#buildError = cause; this.#building = false; - for (const worker of this.#workers) { - worker.close(); - } + for (const worker of [...this.#workers]) { + worker.close(); + } }); reload() { - for (const worker of this.#workers) { - worker.close(); - } + for (const worker of [...this.#workers]) { + worker.close(); + } const worker = new NodeEnvRunner({Also applies to: 156-183
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (12)
src/build/vite/dev.ts(2 hunks)src/build/vite/env.ts(3 hunks)src/build/vite/plugin.ts(2 hunks)src/build/vite/types.ts(2 hunks)src/dev/app.ts(1 hunks)src/dev/server.ts(4 hunks)src/runner/node.ts(7 hunks)src/runtime/internal/vite/node-runner.mjs(2 hunks)src/types/config.ts(1 hunks)src/types/hooks.ts(2 hunks)src/types/index.ts(1 hunks)src/types/runner.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (8)
src/types/hooks.ts (1)
src/runner/node.ts (1)
EnvRunnerData(18-21)
src/build/vite/plugin.ts (2)
src/build/vite/env.ts (1)
getEnvRunner(11-17)src/dev/app.ts (1)
NitroDevApp(19-99)
src/build/vite/types.ts (1)
src/types/runner.ts (1)
EnvRunner(27-34)
src/build/vite/env.ts (3)
src/build/vite/types.ts (1)
NitroPluginContext(59-72)src/runner/node.ts (1)
NodeEnvRunner(23-221)src/runtime/meta.ts (1)
runtimeDir(9-9)
src/build/vite/dev.ts (1)
src/build/vite/env.ts (1)
getEnvRunner(11-17)
src/runtime/internal/vite/node-runner.mjs (1)
src/dev/server.ts (1)
error(226-269)
src/dev/server.ts (2)
src/types/runner.ts (3)
RunnerRPCHooks(14-18)EnvRunner(27-34)RunnerMessageListener(6-6)src/runner/node.ts (2)
EnvRunnerData(18-21)NodeEnvRunner(23-221)
src/runner/node.ts (1)
src/types/runner.ts (3)
EnvRunner(27-34)WorkerHooks(22-25)RunnerMessageListener(6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: tests-rollup (ubuntu-latest)
- GitHub Check: tests-rollup (windows-latest)
- GitHub Check: tests-rolldown (windows-latest)
🔇 Additional comments (14)
src/dev/app.ts (1)
12-12: Import path change is valid and correctly refactored.The module now exists at
src/runner/proxy.tswith thecreateHTTPProxyexport. The old module has been removed fromsrc/dev/proxy.ts, and usage remains unchanged.src/types/config.ts (1)
176-180: Inline type definition is safe—no breaking changes detected.Verification confirms that
NitroDevServerOptionsis not referenced anywhere in the codebase and was not part of the public API. The inline type definition preserves the three essential fields (port, hostname, watch) and simplifies the configuration structure without side effects.src/types/index.ts (1)
4-4: LGTM!The export change correctly aligns with the refactoring from
DevWorkertoEnvRunnertypes. The newrunner.tsmodule properly consolidates the runner-related type exports.src/build/vite/dev.ts (2)
17-17: LGTM!The import correctly brings in
getEnvRunnerfor the refactored upgrade handler integration.
135-135: LGTM!The upgrade handler delegation is correctly refactored to use
getEnvRunner(ctx). The optional chaining onupgrade?.()is appropriate since the method may not be implemented on all runner types.src/types/runner.ts (2)
6-6: LGTM!The type rename from
DevMessageListenertoRunnerMessageListeneraligns with the broader refactoring.
14-18: LGTM!The interface rename to
RunnerRPCHooksis consistent with the refactoring, and the method signatures correctly use the renamedRunnerMessageListenertype.src/runtime/internal/vite/node-runner.mjs (1)
193-197: LGTM!Clean shutdown handling implementation. The server is properly closed before signaling exit to the parent, ensuring graceful termination.
src/types/hooks.ts (2)
1-1: LGTM!The import correctly references the new
EnvRunnerDatatype from the refactored runner module location.
14-17: LGTM!The
dev:reloadhook payload correctly uses the renamedEnvRunnerDatatype, maintaining consistency with the broader refactoring.src/build/vite/types.ts (1)
3-3: EnvRunner type and context field wiring look consistentImporting
EnvRunnerand caching it onNitroPluginContext._envRunneraligns with the newgetEnvRunner(ctx)helper and keeps the runner clearly scoped per plugin context; no issues from a typing or lifecycle perspective.Also applies to: 68-72
src/build/vite/env.ts (1)
4-17: Shared EnvRunner caching and wiring across environments looks correct
getEnvRunner(ctx)properly memoizes aNodeEnvRunneronctx._envRunner, and bothcreateNitroEnvironmentandcreateServiceEnvironmentnow pass that shared runner intocreateFetchableDevEnvironment, which matches the intended reuse of environment runner logic across dev/service environments without obvious downsides.Also applies to: 45-52, 78-85
src/dev/server.ts (1)
5-7: Dev server runner refactor to EnvRunner/RunnerRPCHooks is coherentSwitching to
NodeEnvRunner/EnvRunnerData, storingEnvRunner[]in#workers, and implementingRunnerRPCHooks(includingsendMessage,onMessage,offMessage) keeps the dev server aligned with the new runner abstractions. The construction ofNodeEnvRunnerinreload()withdata: this.#workerDataand the propagation of message listeners to each active worker all look consistent with the updatedNodeEnvRunnerAPI.Also applies to: 29-40, 160-177, 185-205
src/runner/node.ts (1)
5-9: NodeEnvRunner implementation matches the new EnvRunner/RunnerRPCHooks contractsThe refactor to
EnvRunnerDataandNodeEnvRunner implements EnvRunner—includingRunnerMessageListener-typedonMessage/offMessage, the updated 503 message infetch, and the clearer force-close warning—lines up with the new runner typings and expected behavior, with no apparent correctness or lifecycle issues.Also applies to: 18-21, 23-24, 28-40, 67-72, 92-99, 101-107, 122-126, 196-203
Runner part from dev server initially refactored as DevWorker primitive.
For purposes other than development mode (preview and testing), we can reuse same logic from env runner.
This PR does initial refactors.