mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
fix: add missing HandleScope in contentTracing.getTraceBufferUsage() (#50594)
The `OnTraceBufferUsageAvailable` callback creates V8 handles via `Dictionary::CreateEmpty()` before `promise.Resolve()` enters its `SettleScope` (which provides a `HandleScope`). When the callback fires asynchronously from a Mojo response (i.e. when a trace session is active), there is no `HandleScope` on the stack, causing a fatal V8 error: "Cannot create a handle without a HandleScope". Add an explicit `v8::HandleScope` at the top of the callback, matching the pattern used by the other contentTracing APIs which resolve their promises through `SettleScope` or the static `ResolvePromise` helper. Made-with: Cursor Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Alexey Kozy <alexey@anysphere.co>
This commit is contained in:
@@ -151,7 +151,10 @@ void OnTraceBufferUsageAvailable(
|
||||
gin_helper::Promise<gin_helper::Dictionary> promise,
|
||||
float percent_full,
|
||||
size_t approximate_count) {
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(promise.isolate());
|
||||
v8::Isolate* isolate = promise.isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("percentage", percent_full);
|
||||
dict.Set("value", approximate_count);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user