aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/BunInspector.cpp11
-rw-r--r--src/bun.js/bindings/BunInspector.h1
-rw-r--r--src/bun.js/event_loop.zig9
3 files changed, 20 insertions, 1 deletions
diff --git a/src/bun.js/bindings/BunInspector.cpp b/src/bun.js/bindings/BunInspector.cpp
index a88823edd..4790c5a60 100644
--- a/src/bun.js/bindings/BunInspector.cpp
+++ b/src/bun.js/bindings/BunInspector.cpp
@@ -2,6 +2,7 @@
#include <JavaScriptCore/Heap.h>
#include <JavaScriptCore/JSGlobalObject.h>
#include "JSGlobalObjectInspectorController.h"
+#include <JavaScriptCore/JSGlobalObjectDebugger.h>
namespace Zig {
@@ -111,6 +112,8 @@ void BunInspector::drainOutgoingMessages()
}
}
+extern "C" void Bun__tickWhileWaitingForDebugger(JSC::JSGlobalObject* globalObject);
+
RefPtr<BunInspector> BunInspector::startWebSocketServer(
WebCore::ScriptExecutionContext& context,
WTF::String hostname,
@@ -184,7 +187,13 @@ RefPtr<BunInspector> BunInspector::startWebSocketServer(
*connectionPtr = new BunInspectorConnection(inspector);
ws->subscribe("BunInspectorConnection");
BunInspectorConnection* connection = *connectionPtr;
- inspector->connect(Inspector::FrontendChannel::ConnectionType::Local); },
+ inspector->connect(Inspector::FrontendChannel::ConnectionType::Local);
+ auto* debugger = reinterpret_cast<Inspector::JSGlobalObjectDebugger*>(inspector->globalObject()->inspectorController().debugger());
+ debugger->runWhilePausedCallback = [](JSC::JSGlobalObject& globalObject, bool& isPaused) {
+ while (isPaused) {
+ Bun__tickWhileWaitingForDebugger(&globalObject);
+ }
+ }; },
.message = [inspector](auto* ws, std::string_view message, uWS::OpCode opCode) {
if (opCode == uWS::OpCode::TEXT) {
diff --git a/src/bun.js/bindings/BunInspector.h b/src/bun.js/bindings/BunInspector.h
index 219cfdcf3..c02e810cb 100644
--- a/src/bun.js/bindings/BunInspector.h
+++ b/src/bun.js/bindings/BunInspector.h
@@ -11,6 +11,7 @@
namespace Zig {
using namespace JSC;
+using namespace WebCore;
class BunInspector final : public RefCounted<BunInspector>, ::Inspector::InspectorTarget, ::Inspector::FrontendChannel, public WebCore::ContextDestructionObserver {
public:
diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig
index c2125e64f..04935c79b 100644
--- a/src/bun.js/event_loop.zig
+++ b/src/bun.js/event_loop.zig
@@ -879,3 +879,12 @@ pub const AnyEventLoop = union(enum) {
}
}
};
+
+pub export fn Bun__tickWhileWaitingForDebugger(globalObject: *JSC.JSGlobalObject) callconv(.C) void {
+ globalObject.bunVM().eventLoop().tickPossiblyForever();
+}
+
+comptime {
+ if (!JSC.is_bindgen)
+ _ = Bun__tickWhileWaitingForDebugger;
+}