Skip to content
File

Blob: patches/v8/0007-Randomize-the-initial-ExecutionContextId-used-by-the.patch

1.2 KB
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Orion Hodson <orion@cloudflare.com>
3Date: Wed, 13 Sep 2023 15:38:15 +0100
4Subject: Randomize the initial ExecutionContextId used by the inspector
5 
6This is to help the devtools sources panel when workerd is re-started
7by miniflare. This happens because workerd does not support re-loading
8live workers (https://chat.google.com/room/AAAAnS2bXT4/GX5-pa8O0ts).
9 
10Signed-off-by: James M Snell <jsnell@cloudflare.com>
11 
12diff --git a/src/inspector/v8-inspector-impl.cc b/src/inspector/v8-inspector-impl.cc
13index b57097472e2d55128a3b116c6c613a3cefccfe56..d1d3f312234a11776d98c67a874ef0c62c324a56 100644
14--- a/src/inspector/v8-inspector-impl.cc
15+++ b/src/inspector/v8-inspector-impl.cc
16@@ -68,7 +68,7 @@ V8InspectorImpl::V8InspectorImpl(v8::Isolate* isolate,
17 m_client(client),
18 m_debugger(new V8Debugger(isolate, this)),
19 m_lastExceptionId(0),
20- m_lastContextId(0) {
21+ m_lastContextId(static_cast<int32_t>(generateUniqueId() & 0x1fff'ffe0)) {
22 v8::debug::SetInspector(m_isolate, this);
23 v8::debug::SetConsoleDelegate(m_isolate, console());
24 v8::debug::SetIsolateId(m_isolate, generateUniqueId());