feat: add bun runtime support - #2838
Conversation
|
Hi @euxaristia, thank you for your contribution! bun support is on our roadmap as a next-step feature. We'll conduct a thorough design review before merging this PR, so we'll need some additional time to evaluate it properly. |
|
Ok I will fix these issues soon, my CachyOS bricked itself so I need some time to reinstall. I should be able to address the requested changes in a week or less. |
Add opt-in Bun runtime support for running Qwen Code with Bun. Changes: - Detect Bun at runtime and disable node-pty (avoids EAGAIN errors under Bun's incomplete native-addon support) via shouldDefaultToNodePty() - Use bun for build/start scripts (scripts/build.js, scripts/start.js, scripts/check-build-status.js) - Use bun for bundle/prepare npm scripts (package.json) - Add ink@6.2.3 patch to silently handle react-devtools-core incompatibility with Bun - Add bun.lock for deterministic Bun installs - Update husky pre-commit to use bun - Update VSCode companion NOTICES.txt with Bun-added deps Node.js users are unaffected by the shebang, package metadata, or published dependency set; the CLI binary still reports #!/usr/bin/env node. Tested on Linux with Bun 1.3.10. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
ca759aa to
084e2b2
Compare
|
Thanks for the thorough review, @wenshao. My machine is finally back, so I just pushed a rebased version that addresses most of the comments. Summary:
Still outstanding — need your guidance (comments on The current branch still makes
Option (1) is what I'd default to, but I'd rather match your intent than guess. Happy to implement whichever you prefer — or a different shape you have in mind. |
wenshao
left a comment
There was a problem hiding this comment.
The added bun.lock appears to be generated from stale or incomplete manifests. For example, it records @lydell/node-pty packages as 1.1.0 while the current manifests and npm lock use 1.2.0-beta.10; workspace versions are also stale (0.13.2 vs current 0.15.2), channel workspace dependencies used by the CLI are missing, and react-devtools-core is locked to a different major than package.json. This makes Bun installs resolve a dependency graph that does not match the committed manifests, so Bun builds/tests are not reproducible from the PR as written. Please regenerate bun.lock from a clean checkout with the current workspace manifests and verify it matches the committed package metadata.
— gpt-5.5 via Qwen Code /review
…v var, regenerate bun.lock, restore NOTICES.txt, fix ink patch - Revert package.json scripts (bundle, prepare) to use npm by default - Make build.js and start.js use QWEN_RUNTIME=bun env var for opt-in Bun support - Regenerate bun.lock from clean manifests (fixes stale versions) - Restore NOTICES.txt to upstream (Bun regeneration caused license text issues) - Make ink patch more targeted (preserve ERR_MODULE_NOT_FOUND warning, only suppress in Bun) - Revert .husky/pre-commit and check-build-status.js messages to npm
|
Thanks for the thorough reviews, @wenshao. I've pushed a new commit that addresses all outstanding comments: Round 2 fixes:
Also fixed (collateral from earlier round):
The approach for opt-in Bun support uses |
DragonnZhang
left a comment
There was a problem hiding this comment.
LGTM! ✅ The PR has been significantly improved since the last review. All 17 previously raised Critical issues are now addressed:\n\n- CLI shebang restored to #!/usr/bin/env node — Node-only installations unaffected\n- All npm scripts (build, start, bundle, prepare) default to npm; Bun is opt-in via QWEN_RUNTIME=bun\n- esbuild.config.js, eslint.config.js, workspaces config — unchanged from main\n- NOTICES.txt restored to upstream\n- ink patch now targeted (preserves ERR_MODULE_NOT_FOUND warning, only suppresses Bun-specific errors)\n\nActual code diff from main is just 5 files, +54/-6 lines (excluding bun.lock and NOTICES.txt). Clean, minimal, and well-scoped.\n\nOne minor suggestion: consider documenting the QWEN_RUNTIME=bun environment variable in README or contributing docs so Bun users can discover the opt-in path.\n\nCI passes on all platforms (macOS/Ubuntu/Windows, Node 22.x). — Qwen Code /review
|
I've addressed your review comment. |
|
Thanks for the substantial effort here, @euxaristia — and for reworking it to be opt-in ( After consideration, we're going to hold off on adopting Bun as a second runtime for now. This is about ongoing cost rather than the quality of the PR: maintaining a parallel So I'm closing this as a deliberate "not right now" rather than a rejection of the idea. If we decide to take on a second runtime as an intentional initiative, this is a strong starting point and we'd revisit it. Thank you again for pushing it this far. 🙏 |
TLDR
Add support for running Qwen Code with Bun runtime for significantly improved performance. Bun provides faster startup times, lower memory usage, and native TypeScript support compared to Node.js.
Dive Deeper
Why Bun?
Bun is a modern JavaScript runtime that offers:
Changes
Core Runtime Changes
#!/usr/bin/env nodeto#!/usr/bin/env bunbuninstead ofnode/npmDependencies
Technical Details
node-pty Detection (
packages/core/src/utils/shell-utils.ts):ink Patch (
patches/ink@6.2.3.patch):Testing
Tested on Linux with Bun 1.3.10:
How to Use
Users can now run Qwen Code with Bun:
Migration Notes
Reviewer Test Plan
curl -fsSL https://bun.sh/install | bashgit checkout feat/bun-runtime-supportbun installbun startTesting Matrix
Note: This PR migrates the project to use Bun as the primary runtime. Tested on Linux with Bun 1.3.10. macOS and Windows testing would benefit from community validation.
Linked issues / bug
Related to performance improvements and runtime flexibility