Repository navigation
Propagate debugger CLI config in single-file executables - #25600
Conversation
|
Updated 11:10 PM PT - Dec 18th, 2025
@Jarred-Sumner, your commit 166cf80 is building: |
WalkthroughRuntime options wiring is added in two initialization contexts: the Run struct now captures smol, debugger, and parsed dns_result_order from ctx.runtime_options in bootStandalone; the VM initialization sets is_main_thread and updates is_smol_mode flags. Changes
Possibly related PRs
Suggested reviewers
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/bun.js/VirtualMachine.zig (1)
1057-1074: Critical: Missing assignments fordns_result_orderandsmoloptions.The
dns_result_orderandsmoloptions are passed viaoptsbut never assigned to the VM instance fields. This means these runtime options won't take effect for standalone executables.🔎 Add missing field assignments
if (opts.is_main_thread) { VMHolder.main_thread_vm = vm; vm.is_main_thread = true; } is_smol_mode = opts.smol; + vm.smol = opts.smol; + vm.dns_result_order = opts.dns_result_order; vm.global = JSGlobalObject.create(For reference, the regular
initfunction assigns both fields at lines 1195-1196:vm.smol = opts.smol; vm.dns_result_order = opts.dns_result_order;
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/bun.js.zig(1 hunks)src/bun.js/VirtualMachine.zig(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.{cpp,zig}
📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)
src/**/*.{cpp,zig}: Usebun bdorbun run build:debugto build debug versions for C++ and Zig source files; creates debug build at./build/debug/bun-debug
Run tests usingbun bd test <test-file>with the debug build; never usebun testdirectly as it will not include your changes
Execute files usingbun bd <file> <...args>; never usebun <file>directly as it will not include your changes
Enable debug logs for specific scopes usingBUN_DEBUG_$(SCOPE)=1environment variable
Code generation happens automatically as part of the build process; no manual code generation commands are required
Files:
src/bun.js/VirtualMachine.zigsrc/bun.js.zig
src/**/*.zig
📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)
Use
bun.Output.scoped(.${SCOPE}, .hidden)for creating debug logs in Zig codeImplement core functionality in Zig, typically in its own directory in
src/
src/**/*.zig: Private fields in Zig are fully supported using the#prefix:struct { #foo: u32 };
Use decl literals in Zig for declaration initialization:const decl: Decl = .{ .binding = 0, .value = 0 };
Prefer@importat the bottom of the file (auto formatter will move them automatically)
Files:
src/bun.js/VirtualMachine.zigsrc/bun.js.zig
**/*.zig
📄 CodeRabbit inference engine (.cursor/rules/zig-javascriptcore-classes.mdc)
**/*.zig: Expose generated bindings in Zig structs usingpub const js = JSC.Codegen.JS<ClassName>with trait conversion methods:toJS,fromJS, andfromJSDirect
Use consistent parameter nameglobalObjectinstead ofctxin Zig constructor and method implementations
Usebun.JSError!JSValuereturn type for Zig methods and constructors to enable proper error handling and exception propagation
Implement resource cleanup usingdeinit()method that releases resources, followed byfinalize()called by the GC that invokesdeinit()and frees the pointer
UseJSC.markBinding(@src())in finalize methods for debugging purposes before callingdeinit()
For methods returning cached properties in Zig, declare external C++ functions usingextern fnandcallconv(JSC.conv)calling convention
Implement getter functions with naming patternget<PropertyName>in Zig that acceptthisandglobalObjectparameters and returnJSC.JSValue
Access JavaScript CallFrame arguments usingcallFrame.argument(i), check argument count withcallFrame.argumentCount(), and getthiswithcallFrame.thisValue()
For reference-counted objects, use.deref()in finalize instead ofdestroy()to release references to other JS objectsIn Zig code, be careful with allocators and use defer for cleanup
Files:
src/bun.js/VirtualMachine.zigsrc/bun.js.zig
🧠 Learnings (6)
📚 Learning: 2025-11-24T18:35:39.205Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/registering-bun-modules.mdc:0-0
Timestamp: 2025-11-24T18:35:39.205Z
Learning: Add tests for new Bun runtime functionality
Applied to files:
src/bun.js.zig
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to src/bun.js/bindings/generated_classes_list.zig : Include new class bindings in `src/bun.js/bindings/generated_classes_list.zig` to register them with the code generator
Applied to files:
src/bun.js.zig
📚 Learning: 2025-11-24T18:34:55.173Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/building-bun.mdc:0-0
Timestamp: 2025-11-24T18:34:55.173Z
Learning: Applies to src/**/*.{cpp,zig} : Use `bun bd` or `bun run build:debug` to build debug versions for C++ and Zig source files; creates debug build at `./build/debug/bun-debug`
Applied to files:
src/bun.js.zig
📚 Learning: 2025-10-16T02:17:35.237Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/analytics.zig:15-21
Timestamp: 2025-10-16T02:17:35.237Z
Learning: In src/analytics.zig and similar files using bun.EnvVar boolean environment variables: the new EnvVar API for boolean flags (e.g., bun.EnvVar.do_not_track.get(), bun.EnvVar.ci.get()) is designed to parse and return boolean values from environment variables, not just check for their presence. This is an intentional design change from the previous presence-based checks using bun.getenvZ().
Applied to files:
src/bun.js.zig
📚 Learning: 2025-10-17T20:50:58.644Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23755
File: src/bun.js/api/bun/socket/Handlers.zig:154-159
Timestamp: 2025-10-17T20:50:58.644Z
Learning: In Bun socket configuration error messages (src/bun.js/api/bun/socket/Handlers.zig), use the user-facing JavaScript names "data" and "drain" instead of internal field names "onData" and "onWritable", as these are the names users see in the API according to SocketConfig.bindv2.ts.
Applied to files:
src/bun.js.zig
📚 Learning: 2025-11-24T18:37:11.466Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/js/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:37:11.466Z
Learning: Write JS builtins for Bun's Node.js compatibility and APIs, and run `bun bd` after changes
Applied to files:
src/bun.js.zig
🔇 Additional comments (1)
src/bun.js.zig (1)
41-43: Runtime options are properly consumed by the VM.The wiring of
smol,debugger, anddns_result_orderfromctx.runtime_optionsis correct. InVirtualMachine.initWithModuleGraph,vm.smolandvm.dns_result_orderare properly assigned at lines 1195-1196, and thedebuggeroption is configured viavm.configureDebugger(opts.debugger)at line 1202.
| VMHolder.main_thread_vm = vm; | ||
| vm.is_main_thread = true; | ||
| } | ||
| is_smol_mode = opts.smol; |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Inconsistent pattern for is_smol_mode assignment.
The unconditional assignment is_smol_mode = opts.smol differs from the conditional pattern in the init function (lines 1198-1199), which only sets it when opts.smol is true. While functionally equivalent (since setting to false matches the default), consistency would improve maintainability.
🔎 Make the pattern consistent
if (opts.is_main_thread) {
VMHolder.main_thread_vm = vm;
vm.is_main_thread = true;
}
- is_smol_mode = opts.smol;
+ if (opts.smol)
+ is_smol_mode = opts.smol;🤖 Prompt for AI Agents
In src/bun.js/VirtualMachine.zig around line 1061, the code unconditionally
assigns is_smol_mode = opts.smol which is inconsistent with the init function
(lines 1198-1199) that only sets the flag when opts.smol is true; change the
assignment to only set is_smol_mode when opts.smol is true (e.g., guard the
assignment with an if (opts.smol) so the flag is only changed when explicitly
enabled) to match the existing pattern and maintain consistency.
What does this PR do?
How did you verify your code works?