-
-
Notifications
You must be signed in to change notification settings - Fork 834
fix(vite): support Bun-only dev server #4310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
puneetdixit200
wants to merge
1
commit into
nitrojs:main
Choose a base branch
from
puneetdixit200:fix/bun-dev-runner-response
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+85
β11
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| const { normalizeBunResponse } = await import("../../src/runtime/internal/vite/dev-worker.mjs"); | ||
|
|
||
| describe("vite dev worker", () => { | ||
| it("leaves responses untouched outside Bun", () => { | ||
| const response = new Response("ok", { | ||
| headers: { "content-length": "2" }, | ||
| }); | ||
|
|
||
| expect(normalizeBunResponse(response)).toBe(response); | ||
| }); | ||
|
|
||
| it("drops explicit content length before Bun serves the response", async () => { | ||
| vi.stubGlobal("Bun", {}); | ||
| try { | ||
| const response = normalizeBunResponse( | ||
| new Response("ok", { | ||
| headers: { | ||
| "content-length": "2", | ||
| "content-type": "text/plain", | ||
| }, | ||
| }) | ||
| ); | ||
|
|
||
| expect(response).toBeInstanceOf(Response); | ||
| expect(response.headers.has("content-length")).toBe(false); | ||
| expect(response.headers.get("content-type")).toBe("text/plain"); | ||
| expect(await response.text()).toBe("ok"); | ||
| } finally { | ||
| vi.unstubAllGlobals(); | ||
| } | ||
| }); | ||
| }); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π§© Analysis chain
π Script executed:
Repository: nitrojs/nitro
Length of output: 234
π Script executed:
Repository: nitrojs/nitro
Length of output: 4259
π Web query:
unjs env-runner 0.1.9 RunnerName bun-processπ‘ Result:
The BunProcessEnvRunner is a specific runner class provided by the unjs/env-runner library designed to execute server applications using the Bun runtime or a Node.js process [1][2]. Key details regarding the runner: Isolation: It operates by spawning a child process using Bun or Node.js [1][2]. IPC Mechanism: It utilizes Bun's spawn IPC or Node.js's fork mechanism for inter-process communication [1][2]. Usage: It is one of the available runners supported by the env-runner package, which can be selected via the --runner bun-process CLI flag or imported directly from env-runner/runners/bun-process [2]. The env-runner library is a generic environment runner that supports various runtimes and deployment contexts, including Node.js (worker threads and child processes), Bun, Deno, Cloudflare Workers (via miniflare), Vercel, and Netlify [1][3]. As of June 2026, the project continues to receive updates to its runner implementations [3][4].
Citations:
π Web query:
env-runner@0.1.9 RunnerName "bun-process" typeπ‘ Result:
In the env-runner package, "bun-process" is a valid member of the RunnerName type [1][2]. It refers to a runner that executes applications in a separate process using the Bun runtime, utilizing Bun.spawn for IPC (Inter-Process Communication) or Node.js-style fork mechanisms [3][4][5]. The RunnerName type is a union of strings used to specify which environment runner should be utilized [1][2]. As of the current version, the available runners include: - node-worker [4][5] - node-process [4][5] - bun-process [4][5] - deno-process [4][5] - self [4][5] - miniflare [4][5] - vercel [1] - netlify [1] Users can select a runner via the --runner flag in the CLI or through configuration options in tools like Nitro [4][5][2]. The "bun-process" runner specifically provides isolation by running the target application as a child process with the Bun runtime [3][4].
Citations:
Remove duplicated
getDefaultDevRunnerName()helper to prevent drift.getDefaultDevRunnerName()is defined identically in bothsrc/build/vite/env.ts(lines 255-259) andsrc/dev/server.ts(lines 254-258). Extract it into a shared internal utility and import it in both places to avoid divergence."bun-process"is a validRunnerNamein the repoβsenv-runner@^0.1.9dependency, so no change is needed there.π€ Prompt for AI Agents