Commit Graph

62 Commits

Author SHA1 Message Date
Alistair Smith
831f901e2d Merge branch 'ali/inspector-cdp-pause' of github.com:oven-sh/bun into ali/inspector-cdp-pause 2026-02-17 14:47:24 -08:00
Alistair Smith
87838209db fix: restore connected for isBootstrap check
The activated change broke inspector activation entirely.
Revert to connected which was the working state.
2026-02-17 14:12:32 -08:00
autofix-ci[bot]
4c61221eb4 [autofix.ci] apply automated fixes 2026-02-17 20:28:22 +00:00
Alistair Smith
d95e006879 try fix race 2026-02-17 12:25:56 -08:00
Alistair Smith
9a2c9b3394 fix: drain CDP messages after doConnect to prevent message loss on reconnect
receiveMessagesOnInspectorThread was draining messages from the queue
before checking if the connection needed doConnect. If the connection
was Pending, it called doConnect and returned early, dropping the
already-drained messages on the floor.

Move the doConnect check before the message drain so messages that
arrive during reconnection are not lost.
2026-02-17 11:48:55 -08:00
Alistair Smith
b20003779f this is definitely wrong 2026-02-13 18:49:10 -08:00
Alistair Smith
4a9c54d03b fix: safely write usePollingTraps by temporarily unprotecting frozen JSC config page 2026-02-13 17:36:34 -08:00
Alistair Smith
49c2ef2732 fix: remove write to frozen JSC::Options::usePollingTraps (segfault on Linux)
The options page is mprotected read-only after JSC initialization.
Writing to usePollingTraps from Bun__activateRuntimeInspectorMode crashes
with SEGV at offset 0xB34 (the usePollingTraps field offset in the frozen page).
Confirmed via ASAN on Linux aarch64.
2026-02-13 17:16:57 -08:00
Alistair Smith
7c136691a8 refactor(inspector): clean up BunDebugger.cpp naming and duplication
- Rename Bun__setRuntimeInspectorActivated → Bun__activateRuntimeInspectorMode
- Rename Bun__activateInspector → Bun__tryActivateInspector
- Rename Bun__jsDebuggerCallback → Bun__stopTheWorldCallback
- Extract forEachConnection/forEachConnectionForVM iteration helpers
- Merge findVMWithPendingConnections + findVMWithPendingPause → findVMWithPendingWork
- Extract installRunWhilePausedCallback and makeInspectable helpers
- Remove duplicate Bun__tickWhilePaused declarations
- Remove unnecessary messages.clear() before destructor
- Fix stale comment on kMessageDeliveryPause
2026-02-13 13:58:01 -08:00
Alistair Smith
fd1df3f892 fix declare 2026-02-13 13:44:44 -08:00
Alistair Smith
22ca21dce5 cleanup: use Bun__setRuntimeInspectorActivated in STW path too 2026-02-13 13:40:20 -08:00
Alistair Smith
68eeae70f3 fix: set usePollingTraps in event loop activation path to stop SignalSender 2026-02-13 13:38:27 -08:00
Alistair Smith
7eda29f2d6 fix: cancel VM stop in event loop activation path to prevent residual trap crash
When the event loop path wins the race against STW for inspector activation,
requestResumeAll() doesn't clear the VM's trap bits (world was never stopped).
The residual NeedStopTheWorld trap + poisoned stack limit then crashes when JS
next enters a function. Fix by explicitly calling vm.cancelStop() before
requestResumeAll() on the event loop path.
2026-02-13 13:09:44 -08:00
Alistair Smith
5bc8d247e0 set JSC::Options::usePollingTraps() = true; when the inspector starts because all js code will get recompiled and polling traps allow us to guarantee hitting STW 2026-02-12 17:57:52 -08:00
Alistair Smith
32abcf8736 some fixes 2026-02-11 17:30:31 -08:00
autofix-ci[bot]
5c165f8ab2 [autofix.ci] apply automated fixes 2026-02-11 07:06:31 +00:00
Alistair Smith
5fc0806f8c cleanup debugger file and tests 2026-02-10 22:14:31 -08:00
Alistair Smith
2df14412e3 simplify the atomics a bunch 2026-02-10 21:39:36 -08:00
Alistair Smith
3ba2cb888a fix the race + some pr review 2026-02-10 21:31:40 -08:00
Alistair Smith
d288559fd2 fix: replace preAttachedDebugger with runtimeInspectorActivated, add reconnection test
preAttachedDebugger was per-connection and broke on reconnect — a new
connection after disconnect wouldn't have the flag set (debugger already
attached from first connection), so interruptForMessageDelivery would
skip requestStopAll. Using the global runtimeInspectorActivated flag
fixes reconnection and eliminates a redundant atomic bool.

Added test verifying CDP messages work after client disconnect/reconnect.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-10 16:25:45 -08:00
Alistair Smith
0fee9b809b fix: guard pre-attach debugger with runtimeInspectorActivated to fix Windows hang
The pre-attach code in doConnect() was firing for --inspect too (debugger
isn't attached at doConnect time, only after Debugger.enable CDP command).
This set preAttachedDebugger=true, causing interruptForMessageDelivery to
call requestStopAll for every CDP message — deadlocking on Windows.

Gate the pre-attach on runtimeInspectorActivated so it only fires for
the SIGUSR1 path where it's actually needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-10 16:14:39 -08:00
Alistair Smith
bf15eb7955 fix: deduplicate pre-attach comment in doConnect
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-10 15:28:18 -08:00
Alistair Smith
2e2159a9c3 fix: address coderabbit review - clarify pre-attach guard, fix hardcoded port
Improve the comment on the pre-attach debugger guard to explain why it
only fires on the SIGUSR1 path (--inspect already has the debugger
attached by JSC at startup). Replace hardcoded port 6499 assertion in
Windows test with regex match.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-10 15:21:54 -08:00
Alistair Smith
81028e08a7 fix: address review - make preAttachedDebugger atomic, document STW threading safety
Make preAttachedDebugger std::atomic<bool> to fix data race between JS
thread (doConnect writer) and debugger thread (interruptForMessageDelivery
reader). Add comments documenting why schedulePauseAtNextOpportunity is
safe during STW, the double requestStopAll rationale with empirical
results, and STW_CONTINUE behavior for non-VMStopped events.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-10 14:45:18 -08:00
Alistair Smith
868d3b6c0b fix: only use STW in connect() for runtime-activated inspector (SIGUSR1)
connect() was unconditionally calling requestStopAll for all inspector
connections, causing --inspect tests to hang because the STW cycle
interfered with normal event loop delivery. Added runtimeInspectorActivated
flag that is only set when the STW callback processes a SIGUSR1 activation,
so connect() only uses requestStopAll on the runtime activation path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-10 12:40:47 -08:00
Alistair Smith
5a4823285c fix: only use requestStopAll for message delivery when debugger was pre-attached
The --inspect flag tests were failing because interruptForMessageDelivery
called requestStopAll for every CDP message, even on the normal --inspect
path where the event loop delivers messages fine. Now we only use
requestStopAll when the debugger was pre-attached during SIGUSR1 activation
(where the event loop may not be running).
2026-02-10 09:44:25 -08:00
Alistair Smith
e56a08d58d fix: address review comments - guard redundant STW requests, add bootstrap pause VM switch 2026-02-10 02:16:36 -08:00
Alistair Smith
be97a9771b WIP: inspector CDP delivery during busy JS execution 2026-02-10 01:05:36 -08:00
Claude Bot
ad01185643 Merge main into ali/sigusr1 2026-01-27 22:53:52 +00:00
Dylan Conway
4071624edd Update WebKit (#26381)
### What does this PR do?
Updates WebKit to
5b6a0ac49b
### How did you verify your code works?

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:38:13 -08:00
Jarred Sumner
b6b3626c14 fix(bindings): handle errors from String.toJS() for oversized strings (#26213)
## Summary

- When a string exceeds `WTF::String::MaxLength` (~4GB),
`bun.String.createUninitialized()` returns a `.Dead` tag
- The C++ layer now properly throws `ERR_STRING_TOO_LONG` when this
happens
- Updated `String.toJS()` in Zig to return `bun.JSError!jsc.JSValue`
instead of just `jsc.JSValue`
- Updated ~40 Zig caller files to handle the error with `try`
- C++ callers updated with `RETURN_IF_EXCEPTION` checks

## Test plan

- [x] `bun bd test test/js/node/buffer.test.js` - 449 tests pass
- [x] `bun bd
test/js/node/test/parallel/test-buffer-tostring-rangeerror.js` - passes

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude Bot <claude-bot@bun.sh>
2026-01-21 13:01:25 -08:00
Alistair Smith
098bcfa318 address coderabbit & DRYify some code that claude wrote twice 2026-01-13 17:16:39 -08:00
Alistair Smith
8990dfc2ef use VMManager StopTheWorld to interrupt infinite loops for SIGUSR1 inspector 2026-01-09 18:01:28 -08:00
SUZUKI Sosuke
699d8b1e1c Upgrade WebKit Dec 24, 2025 (#25684)
- WTFMove → WTF::move / std::move: Replaced WTFMove() macro with
WTF::move() function for WTF types, std::move() for std types
- SortedArrayMap removed: Replaced with if-else chains in
EventFactory.cpp, JSCryptoKeyUsage.cpp
- Wasm::Memory::create signature changed: Removed VM parameter
- URLPattern allocation: Changed from WTF_MAKE_ISO_ALLOCATED to
WTF_MAKE_TZONE_ALLOCATED

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-12-25 14:00:58 -08:00
SUZUKI Sosuke
bffccf3d5f Upgrade WebKit 2025/12/07 (#25429)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Claude Bot <claude-bot@bun.sh>
2025-12-23 22:24:18 -08:00
taylor.fish
4142f89148 Fix unnecessary reinterpret_casts from JSGlobalObject to Zig::GlobalObject (#23387)
(For internal tracking: fixes STAB-1384)
2025-10-16 11:32:29 -07:00
Meghan Denny
6c5b863530 safety: a lot more exception checker progress (#20817) 2025-07-10 15:34:51 -07:00
Jarred Sumner
6274f10096 Make Strong use less ram (#20437)
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <Jarred-Sumner@users.noreply.github.com>
2025-06-17 13:30:58 -07:00
Jarred Sumner
570e6b7e6a Add WebKit Inspector support to Bun's HTTP Server (#19340) 2025-05-03 03:11:55 -07:00
Jarred Sumner
44c97fa591 Add WebKit Inspector support for Bun's Dev Server (#19320)
Co-authored-by: chloe caruso <git@paperclover.net>
Co-authored-by: Zack Radisic <56137411+zackradisic@users.noreply.github.com>
2025-04-29 18:34:26 -07:00
190n
8dc95b041a Fix bun --inspect-brk hanging (#18362) 2025-03-21 13:35:39 -07:00
Meghan Denny
f2c8e63ae1 update to llvm 19 and c++ 23 (#18317)
Co-authored-by: nektro <5464072+nektro@users.noreply.github.com>
2025-03-20 21:44:19 -07:00
190n
ea65a2ad48 Bump WebKit (#17095)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-02-12 22:08:53 -08:00
Meghan Denny
29839737df cpp: synchronize on JSC::getVM since its more likely to be forward compatible (#16688) 2025-01-29 15:50:57 -08:00
190n
c1218b250d Bump WebKit and re-enable IPInt (#16227)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Kai Tamkun <kai@tamkun.io>
2025-01-15 04:06:52 -08:00
Michael H
67e4aec990 attempt to fix debugger (#15788)
Co-authored-by: RiskyMH <RiskyMH@users.noreply.github.com>
2024-12-16 16:34:55 -08:00
Jarred Sumner
0216431c98 Clean up debugger waiting logic (#15469) 2024-11-28 01:34:31 -08:00
Alistair Smith
4117af6e46 feat(vscode-extension) error reporting, qol (#15261)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Co-authored-by: Electroid <Electroid@users.noreply.github.com>
Co-authored-by: Meghan Denny <meghan@bun.sh>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2024-11-22 02:55:21 -08:00
Meghan Denny
663331c56f fix regression in BunJSGlobalObjectDebuggable from most recent webkit upgrade (#14675) 2024-10-18 22:31:39 -07:00
Dylan Conway
bbb41beadc bump webkit (#14497) 2024-10-11 19:44:53 -07:00