fix: ignore VSCode inspector env vars in standalone executables#27662
fix: ignore VSCode inspector env vars in standalone executables#27662
Conversation
BUN_INSPECT, BUN_INSPECT_CONNECT_TO, and BUN_INSPECT_PRELOAD are now ignored when running as a `bun build --compile` standalone executable. This prevents VSCode's debug terminal from unexpectedly enabling the inspector (and potentially hanging) in compiled binaries. Users can still explicitly enable the inspector via BUN_OPTIONS=--inspect. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Updated 11:51 PM PT - Feb 28th, 2026
❌ Your commit
🧪 To try this PR locally: bunx bun-pr 27662That installs a local version of the PR into your bun-27662 --bun |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (3)
WalkthroughModifies debugger configuration and inspector preload handling to detect and bypass environment variables in standalone mode. Adds tests verifying that BUN_INSPECT environment variables are ignored in standalone executables while BUN_OPTIONS remains functional. Changes
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
LGTM - small, well-motivated fix that correctly suppresses VSCode debug env vars in standalone executables while preserving BUN_OPTIONS.
Extended reasoning...
Overview
This PR modifies two source files (VirtualMachine.zig and Arguments.zig) and adds one test file. In VirtualMachine.zig, when configureDebugger runs and the process is a standalone executable (standalone_module_graph != null), BUN_INSPECT and BUN_INSPECT_CONNECT_TO are replaced with empty strings so neither the .unspecified unix nor connect_to branches activate. In Arguments.zig, BUN_INSPECT_PRELOAD is similarly nulled out when StandaloneModuleGraph.get() != null. The .enable path (used by BUN_OPTIONS=--inspect) is unaffected since it flows through the CLI flag, not the env vars.
Security risks
No security concerns. This change reduces attack surface by preventing environment-variable-driven debugger activation in standalone binaries, which are end-user programs.
Level of scrutiny
This is production-critical runtime code, but the change is minimal (two conditional expressions plus one null check) and the logic is easy to verify. The empty-string and null fallbacks cleanly disable the env-var paths without affecting any other control flow.
Other factors
The new test covers both the suppression case (BUN_INSPECT with break=1 no longer hangs) and the pass-through case (BUN_OPTIONS still works). No bugs found by the automated bug hunting system. No outstanding reviewer comments to address.
Summary
BUN_INSPECT,BUN_INSPECT_CONNECT_TO, andBUN_INSPECT_PRELOADenvironment variables are now ignored when running as abun build --compilestandalone executableBUN_OPTIONS(e.g.BUN_OPTIONS=--inspect) continues to work as before, so users can still explicitly enable the inspector in standalone binariesMotivation
When VSCode's Bun extension opens a "JavaScript Debug Terminal", it sets
BUN_INSPECT,BUN_INSPECT_NOTIFY, andBUN_INSPECT_CONNECT_TOin the terminal environment. Running a standalone executable in that terminal would unexpectedly enable the inspector — and with?break=1, hang indefinitely waiting for a debugger connection. Standalone executables are end-user programs that should not be affected by IDE debug instrumentation.Test plan
BUN_INSPECTwith?break=1is ignored in standalone (previously would hang)BUN_OPTIONS=--smolstill works in standalone viaprocess.execArgv🤖 Generated with Claude Code