Skip to content
Open
Show file tree
Hide file tree
Changes from 125 commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
95c987d
Initial work on supporting SIGUSR1
alii Dec 11, 2025
a95584f
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 11, 2025
11e1a10
signal safe handler, some other review notes
alii Dec 11, 2025
b98e7c1
be clear about idempotency
alii Dec 11, 2025
56cddb6
a cheap shot at windows
alii Dec 11, 2025
f265f74
consolidate windows/posix inspector logic with a new struct "RuntimeI…
alii Dec 11, 2025
5696810
get it to compile
alii Dec 11, 2025
a86b965
implement process._debugProcess
alii Dec 11, 2025
a029cd1
split up runtime inspector tests
alii Dec 11, 2025
ee6a1e8
add --disable-sigusr1
alii Dec 11, 2025
ffb5939
fix --disable-sigusr1 test for CI
alii Dec 11, 2025
6ba5e75
fix ban-words: use bun.strings.toWPath and proper struct defaults
alii Dec 11, 2025
4cf5cbe
rm semaphore
alii Dec 12, 2025
329060d
cleaner
alii Dec 12, 2025
3af7ecf
Add tests for SIGUSR1 handling with --inspect-* flags
Dec 12, 2025
602be37
fix(test): replace timing-based waits with condition-based waits in S…
alii Jan 5, 2026
c424d98
fix(test): replace timing-based waits with condition-based waits in W…
alii Jan 5, 2026
2715260
fix(test): replace timing-based waits with condition-based waits in r…
alii Jan 5, 2026
e0b75ef
docs: document inspector port limitation in RuntimeInspector
alii Jan 5, 2026
e0a7775
test: assert exit codes for debug helper processes in runtime-inspect…
alii Jan 5, 2026
0f7a461
test: improve exit code assertion clarity using toBeOneOf
alii Jan 5, 2026
40999fc
Add comment documenting alignment assumption for MapViewOfFile
alii Jan 5, 2026
a13ee96
refactor: extract configureSigusr1Handler helper function
alii Jan 5, 2026
a946a48
Address PR review comments for runtime inspector
alii Jan 5, 2026
852f09c
fix(test): update Windows _debugProcess test to match Bun's error mes…
alii Jan 5, 2026
199fdf4
fix: match Node.js error message for _debugProcess on Windows
alii Jan 5, 2026
c279d12
Skip failing test on Windows for now
Jarred-Sumner Jan 6, 2026
ebe173b
update test expectations, dont print tiwce
alii Jan 7, 2026
48919f8
fix review comments
alii Jan 7, 2026
b080418
use a semaphore and properly inject jsc trap
alii Jan 9, 2026
e50bfa9
do a best effort uninstall case
alii Jan 9, 2026
d6f1b2b
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 9, 2026
cb69a68
use VMManager StopTheWorld to interrupt infinite loops for SIGUSR1 i…
alii Jan 10, 2026
8a7621d
use new WebKit version
alii Jan 12, 2026
1e580b3
Upgrade WebKit to d5bd162d9ab2
Jarred-Sumner Jan 11, 2026
8d1f383
Update WebKit to preview-pr-135-a6fa914b
sosukesuzuki Jan 13, 2026
5ef60b9
Update WEBKIT_VERSION
sosukesuzuki Jan 13, 2026
bb99959
Fix InternalPromise exposure in ReadableStream builtins
sosukesuzuki Jan 13, 2026
47966b4
address coderabbit & DRYify some code that claude wrote twice
alii Jan 14, 2026
cdb3fb8
address review
alii Jan 14, 2026
f497802
fix a case where we'd have a stale jsc trap for a second `kill -USR1 …
alii Jan 14, 2026
b6c06ac
fix race where a second SIGUSR1 leaves stale trap
alii Jan 14, 2026
ab13f51
fix: clean up semaphore if thread spawn fails
Jan 14, 2026
eafbccf
test: check stderr before exit code for better error messages
Jan 14, 2026
b8d1a00
docs: add comment explaining QueuedTask payload parameter
Jan 14, 2026
1d66d98
test: await stderr before checking exit code in runtime-inspector tests
Jan 14, 2026
1a83c78
test: await debug2 stderr before checking exit code
Jan 14, 2026
494e953
Remove comment
Jan 16, 2026
cb867e6
Revert ReadableStreamInternals.ts changes
Jan 16, 2026
7d16d69
Revert Request.zig import reordering
Jan 16, 2026
a7d0bc7
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 16, 2026
7a2e020
Skip flaky SIGUSR1 inspector tests on ASAN builds
Jan 16, 2026
6268d2d
Address CodeRabbit review comments
Jan 17, 2026
44b1f6e
Fix runtime inspector tests: timing and stream reader issues
Jan 27, 2026
ea65b4d
Fix runtime inspector tests to wait for conditions, not time
Jan 27, 2026
67cb732
fix(sigusr1): handle EINTR in sem_wait and skip ASAN for flaky tests
Feb 2, 2026
0058494
fix: address review comments
Feb 2, 2026
0ec2ddc
fix: skip ASAN for flaky inspector test and add timeout handling
Feb 3, 2026
b4ddbb9
fix: improve ASAN detection to check ASAN_OPTIONS env var
Feb 3, 2026
8760775
WIP: inspector CDP delivery during busy JS execution
alii Feb 10, 2026
1874029
fix: address review comments - guard redundant STW requests, add boot…
alii Feb 10, 2026
27cfdf7
fix: only use requestStopAll for message delivery when debugger was p…
alii Feb 10, 2026
805f60d
fix: only use STW in connect() for runtime-activated inspector (SIGUSR1)
alii Feb 10, 2026
23d1b29
fix: remove usePollingTraps to avoid DFG optimization regressions
alii Feb 10, 2026
0715298
fix: address review - make preAttachedDebugger atomic, document STW t…
alii Feb 10, 2026
a8d091a
fix(test): improve runtime inspector test reliability to reduce CI fl…
alii Feb 10, 2026
81774c2
fix: address coderabbit review - clarify pre-attach guard, fix hardco…
alii Feb 10, 2026
d2bae0f
fix: deduplicate pre-attach comment in doConnect
alii Feb 10, 2026
aaeeac7
fix(test): remove all setTimeout from inspector test fixtures
alii Feb 10, 2026
fe42228
revert: undo changes to test/harness.ts
alii Feb 11, 2026
0c7caba
fix: guard pre-attach debugger with runtimeInspectorActivated to fix …
alii Feb 11, 2026
bd58f59
fix: replace preAttachedDebugger with runtimeInspectorActivated, add …
alii Feb 11, 2026
a3ab552
fix(test): remove explicit test timeout per test/CLAUDE.md guidelines
alii Feb 11, 2026
4e8d24f
fix: use WebKit preview build with breakProgram() for reliable while(…
alii Feb 11, 2026
7f940bb
fix the race + some pr review
alii Feb 11, 2026
49a423c
simplify the atomics a bunch
alii Feb 11, 2026
a2fdd29
cleanup debugger file and tests
alii Feb 11, 2026
89b84f6
make runtime-inspector less flaky
alii Feb 11, 2026
6c79c52
[autofix.ci] apply automated fixes
autofix-ci[bot] Feb 11, 2026
afa9bac
revert: use original WebKit version (breakProgram causes test failures)
alii Feb 11, 2026
b46e0bf
revert: restore preview WebKit with breakProgram() (reverts accidenta…
alii Feb 11, 2026
71209a4
try to find a default port with runtime inspector in tests?
alii Feb 11, 2026
ef8fbef
some fixes
alii Feb 12, 2026
201364e
set JSC::Options::usePollingTraps() = true; when the inspector starts…
alii Feb 13, 2026
7dd895e
update WebKit to autobuild-preview-pr-161-c7bcfafe (ali/stw3)
alii Feb 13, 2026
c4f121c
address review comments: fix inspect_port ordering, improve error mes…
alii Feb 13, 2026
d135e6a
fix inspect_port in initBake/second init, reorder exit code assertion…
alii Feb 13, 2026
79eb65d
update WebKit to autobuild-preview-pr-161-aa4d1424 (fix heap walk cra…
alii Feb 13, 2026
dbb0501
fix: cancel VM stop in event loop activation path to prevent residual…
alii Feb 13, 2026
7a313b5
remove accidentally committed printer.js
alii Feb 13, 2026
aa33303
try defer to fix a crash
alii Feb 13, 2026
187d912
fix: set usePollingTraps in event loop activation path to stop Signal…
alii Feb 13, 2026
48fa965
cleanup: use Bun__setRuntimeInspectorActivated in STW path too
alii Feb 13, 2026
72a9b11
fix declare
alii Feb 13, 2026
656d3cc
refactor(inspector): clean up BunDebugger.cpp naming and duplication
alii Feb 13, 2026
c0eb21d
update WebKit to autobuild-preview-pr-161-d796f228 (fix SignalSender …
alii Feb 13, 2026
f7bcbd2
fix: use --inspect-port=0 in posix SIGUSR1 tests to avoid port conflicts
alii Feb 13, 2026
5931ff1
bisect: WebKit with VMTraps.cpp reverted to PR 159 (test if Debugger.…
alii Feb 13, 2026
19547de
fix: remove write to frozen JSC::Options::usePollingTraps (segfault o…
alii Feb 14, 2026
02c2a71
fix: safely write usePollingTraps by temporarily unprotecting frozen …
alii Feb 14, 2026
f6bbb60
this is definitely wrong
alii Feb 14, 2026
91aedcb
update WebKit to autobuild-preview-pr-161-211cf848 (restore CDP drain…
alii Feb 14, 2026
e54ebe3
update WebKit to autobuild-preview-pr-161-0596ebdb (fix agent teardow…
alii Feb 17, 2026
9df9e22
fix: drain CDP messages after doConnect to prevent message loss on re…
alii Feb 17, 2026
3691c80
try fix race
alii Feb 17, 2026
253be47
fix: restore connected for isBootstrap check
alii Feb 17, 2026
ef25e1d
[autofix.ci] apply automated fixes
autofix-ci[bot] Feb 17, 2026
7805244
bump webkit
alii Feb 25, 2026
9aa0c7b
fix webkit upgrade
alii Feb 25, 2026
767039e
Try this
alii Feb 25, 2026
6b60282
Revert "fix webkit upgrade"
alii Feb 25, 2026
e8df6ad
bump webkit pr
alii Feb 25, 2026
b87b8e8
Update WEBKIT_VERSION in TypeScript build system
claude Mar 13, 2026
09ecaa9
Fix deadlock in CDP message drain and macOS semaphore spurious wake
claude Mar 13, 2026
3c18e8e
Fix undeclared identifiers in QueuedTask constructor calls
claude Mar 13, 2026
a8260a1
Remove undeclared 'function' from QueuedTask in ZigGlobalObject.cpp
claude Mar 13, 2026
b100601
Fix baseline CI builds by falling back to non-baseline WebKit
claude Mar 13, 2026
ff2e6dd
Skip baseline suffix for preview WebKit builds in TS build system
claude Mar 13, 2026
f4b79f9
Address review feedback: REPL options, inspector error recovery, test…
claude Mar 14, 2026
aa63081
Fix error recovery in debugger activation and CDP message ordering
claude Mar 14, 2026
226d2f7
Avoid deadlock in runWhilePaused by calling doConnect directly
claude Mar 14, 2026
b1677c6
Revert WebKit version to main: preview build lacks baseline artifacts
claude Mar 14, 2026
b8a7759
Restore 4-param computeLineColumnWithSourcemap signature
claude Mar 14, 2026
975bcb5
Replace isPauseAtNextOpportunitySet with isStepping
claude Mar 14, 2026
87d0f21
Validate pid > 0 in process._debugProcess
claude Mar 14, 2026
ddca4f4
Fix inspector test timeouts, stderr drain, and connect() deadlock guard
claude Mar 14, 2026
79f1d31
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 14, 2026
0aa0eb7
ci: retrigger build
claude Mar 14, 2026
fcad54c
ci: retrigger build
claude Mar 14, 2026
608c32a
Fix recursive runWhilePaused deadlock and stuck inspector_activation_…
claude Mar 14, 2026
7efaa5c
Add strspn to Windows baseline allowlist
claude Mar 14, 2026
600f572
Fix CDP pause for tight loops and add isASAN skip guards
claude Mar 14, 2026
99a6aa3
Skip CDP pause test that requires WebKit VMTraps changes
claude Mar 14, 2026
44c21a5
Merge branch 'main' into ali/inspector-cdp-pause
alii Mar 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bun.js.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pub const Run = struct {
.smol = ctx.runtime_options.smol,
.debugger = ctx.runtime_options.debugger,
.dns_result_order = DNSResolver.Order.fromStringOrDie(ctx.runtime_options.dns_result_order),
.disable_sigusr1 = ctx.runtime_options.disable_sigusr1,
.inspect_port = ctx.runtime_options.inspect_port,
}),
.arena = arena,
.ctx = ctx,
Expand Down Expand Up @@ -186,6 +188,8 @@ pub const Run = struct {
.debugger = ctx.runtime_options.debugger,
.dns_result_order = DNSResolver.Order.fromStringOrDie(ctx.runtime_options.dns_result_order),
.is_main_thread = true,
.disable_sigusr1 = ctx.runtime_options.disable_sigusr1,
.inspect_port = ctx.runtime_options.inspect_port,
},
),
.arena = arena,
Expand Down
7 changes: 5 additions & 2 deletions src/bun.js/Debugger.zig
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ pub fn create(this: *VirtualMachine, globalObject: *JSGlobalObject) !void {
log("create", .{});
jsc.markBinding(@src());
if (!has_created_debugger) {
has_created_debugger = true;
std.mem.doNotOptimizeAway(&TestReporterAgent.Bun__TestReporterAgentDisable);
std.mem.doNotOptimizeAway(&LifecycleAgent.Bun__LifecycleAgentDisable);
std.mem.doNotOptimizeAway(&TestReporterAgent.Bun__TestReporterAgentEnable);
Expand All @@ -128,9 +127,13 @@ pub fn create(this: *VirtualMachine, globalObject: *JSGlobalObject) !void {
debugger.script_execution_context_id = Bun__createJSDebugger(globalObject);
if (!this.has_started_debugger) {
this.has_started_debugger = true;
var thread = try std.Thread.spawn(.{}, startJSDebuggerThread, .{this});
var thread = std.Thread.spawn(.{}, startJSDebuggerThread, .{this}) catch |err| {
this.has_started_debugger = false;
return err;
};
thread.detach();
}
has_created_debugger = true;
this.eventLoop().ensureWaker();

if (debugger.wait_for_connection != .off) {
Expand Down
41 changes: 40 additions & 1 deletion src/bun.js/VirtualMachine.zig
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ hot_reload_counter: u32 = 0,

debugger: ?jsc.Debugger = null,
has_started_debugger: bool = false,
/// Pre-configured inspector port for runtime activation (via --inspect-port).
/// Used by RuntimeInspector when SIGUSR1/process._debugProcess activates the inspector.
inspect_port: ?[]const u8 = null,
has_terminated: bool = false,

debug_thread_id: if (Environment.allow_assert) std.Thread.Id else void,
Expand Down Expand Up @@ -1086,9 +1089,12 @@ pub fn initWithModuleGraph(
vm.jsc_vm = vm.global.vm();
uws.Loop.get().internal_loop_data.jsc_vm = vm.jsc_vm;

vm.inspect_port = opts.inspect_port;
vm.configureDebugger(opts.debugger);
vm.body_value_hive_allocator = Body.Value.HiveAllocator.init(bun.typedAllocator(jsc.WebCore.Body.Value));

configureSigusr1Handler(vm, opts);

return vm;
}

Expand All @@ -1115,8 +1121,28 @@ pub const Options = struct {
/// Worker VMs are always destroyed on exit, regardless of this setting. Setting this to
/// true may expose bugs that would otherwise only occur using Workers.
destruct_main_thread_on_exit: bool = false,
/// Disable SIGUSR1 handler for runtime debugger activation (matches Node.js).
disable_sigusr1: bool = false,
/// Pre-configured inspector port for runtime activation (--inspect-port).
inspect_port: ?[]const u8 = null,
};

/// Configure SIGUSR1 handling for runtime debugger activation (main thread only).
fn configureSigusr1Handler(vm: *const VirtualMachine, opts: Options) void {
if (!opts.is_main_thread) return;

if (opts.disable_sigusr1) {
// User requested --disable-sigusr1, set SIGUSR1 to default action (terminate)
jsc.EventLoop.RuntimeInspector.setDefaultSigusr1Action();
} else if (vm.debugger != null) {
// Debugger already enabled via CLI flags, ignore SIGUSR1
jsc.EventLoop.RuntimeInspector.ignoreSigusr1();
} else {
// Install RuntimeInspector signal handler for runtime activation
jsc.EventLoop.RuntimeInspector.installIfNotAlready();
}
}

pub var is_smol_mode = false;

pub fn init(opts: Options) !*VirtualMachine {
Expand Down Expand Up @@ -1213,9 +1239,12 @@ pub fn init(opts: Options) !*VirtualMachine {
if (opts.smol)
is_smol_mode = opts.smol;

vm.inspect_port = opts.inspect_port;
vm.configureDebugger(opts.debugger);
vm.body_value_hive_allocator = Body.Value.HiveAllocator.init(bun.typedAllocator(jsc.WebCore.Body.Value));

configureSigusr1Handler(vm, opts);

return vm;
}

Expand Down Expand Up @@ -1262,8 +1291,15 @@ fn configureDebugger(this: *VirtualMachine, cli_flag: bun.cli.Command.Debugger)
}
},
.enable => {
// If --inspect/--inspect-brk/--inspect-wait is used without an explicit port,
// use --inspect-port if provided.
const path_or_port = if (cli_flag.enable.path_or_port.len == 0)
this.inspect_port orelse cli_flag.enable.path_or_port
else
cli_flag.enable.path_or_port;

this.debugger = .{
.path_or_port = cli_flag.enable.path_or_port,
.path_or_port = path_or_port,
.from_environment_variable = unix,
.wait_for_connection = if (cli_flag.enable.wait_for_connection) .forever else wait_for_connection,
.set_breakpoint_on_first_line = set_breakpoint_on_first_line or cli_flag.enable.set_breakpoint_on_first_line,
Expand Down Expand Up @@ -1463,9 +1499,12 @@ pub fn initBake(opts: Options) anyerror!*VirtualMachine {
if (opts.smol)
is_smol_mode = opts.smol;

vm.inspect_port = opts.inspect_port;
vm.configureDebugger(opts.debugger);
vm.body_value_hive_allocator = Body.Value.HiveAllocator.init(bun.typedAllocator(jsc.WebCore.Body.Value));

configureSigusr1Handler(vm, opts);

return vm;
}

Expand Down
Loading
Loading