diff options
author | 2023-08-18 19:58:03 -0700 | |
---|---|---|
committer | 2023-08-18 19:58:03 -0700 | |
commit | 943a6642243cbc8a180ab7108279dd7110ab1eaf (patch) | |
tree | 3382acb2c41536e942b8bf09f5f9fd4c97e551f8 /src/js/internal/debugger.ts | |
parent | d0664f83773fc39b8bd6b9ecdfc52833c7ce6b81 (diff) | |
download | bun-943a6642243cbc8a180ab7108279dd7110ab1eaf.tar.gz bun-943a6642243cbc8a180ab7108279dd7110ab1eaf.tar.zst bun-943a6642243cbc8a180ab7108279dd7110ab1eaf.zip |
Remove most C API usages, add debugger pretty printers for `Headers`, `URLSearchParams`, `FormData`, `Worker`, `EventTarget` (#4187)
* Add pretty printers for `Headers`, `URLSearchParams`, and `FormData`
* [untested] Add way to code generate getInternalProperties
* bump
* Bump Webkit
* Ref the event loop while loaded
* wip
* checkpoint
* another checkpoint
* The code has been written
* Fixup exports
* Fix all the errors
* Fix bug
* [console.log] Fix bug when printing non-reified types missing values
* Fix loading hash table
* fix plugin
* Fix ref & unref
* auto-unref
* various fixes
* Update bun.zig
* Set toStringTag
* Delete code for macro JSX
* Delete code for `bun dev` HTTP JS
* Move Bun.serve to C++ API
* Delete JSC C API code
* :scissors: :skull: code
* Use JSC C++ for `confirm`, `Crypto`, `prompt`, `alert`
* more dead code
* Update exports.zig
* Use JSC C++ API for FFI
* Remove remaining usages
* Remove remaining usages
* Update ffi.ts
* Update InternalModuleRegistryConstants.h
* draw the rest of the owl
* Update webcore.zig
* bind it
* Fix performance regression in crypto.randomUIUD()
* Update js_parser.zig
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/js/internal/debugger.ts')
-rw-r--r-- | src/js/internal/debugger.ts | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/js/internal/debugger.ts b/src/js/internal/debugger.ts index 2fd875d10..2b121949a 100644 --- a/src/js/internal/debugger.ts +++ b/src/js/internal/debugger.ts @@ -100,28 +100,35 @@ class WebSocketListener { idleTimeout: 0, open: socket => { var connection = new DebuggerWithMessageQueue(); + // @ts-expect-error + const shouldRefEventLoop = !!socket.data?.shouldRefEventLoop; + socket.data = connection; this.activeConnections.add(socket); - connection.debugger = this.createInspectorConnection(this.scriptExecutionContextId, (...msgs: string[]) => { - if (socket.readyState > 1) { - connection.disconnect(); - return; - } + connection.debugger = this.createInspectorConnection( + this.scriptExecutionContextId, + shouldRefEventLoop, + (...msgs: string[]) => { + if (socket.readyState > 1) { + connection.disconnect(); + return; + } - if (connection.messageQueue.length > 0) { - connection.messageQueue.push(...msgs); - return; - } + if (connection.messageQueue.length > 0) { + connection.messageQueue.push(...msgs); + return; + } - for (let i = 0; i < msgs.length; i++) { - if (!socket.sendText(msgs[i])) { - if (socket.readyState < 2) { - connection.messageQueue.push(...msgs.slice(i)); + for (let i = 0; i < msgs.length; i++) { + if (!socket.sendText(msgs[i])) { + if (socket.readyState < 2) { + connection.messageQueue.push(...msgs.slice(i)); + } + return; } - return; } - } - }); + }, + ); console.log( "[Inspector]", @@ -180,7 +187,14 @@ class WebSocketListener { } if (pathname === this.url) { - if (server.upgrade(req)) { + const refHeader = req.headers.get("Ref-Event-Loop"); + if ( + server.upgrade(req, { + data: { + shouldRefEventLoop: !!refHeader && refHeader !== "0", + }, + }) + ) { return new Response(); } |