mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Merge pull request #1000 from lightpanda-io/log_unhandled_promise_rejections
Log unhandled promise rejection
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
.fingerprint = 0xda130f3af836cea0,
|
.fingerprint = 0xda130f3af836cea0,
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.v8 = .{
|
.v8 = .{
|
||||||
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/e62726800663d0397d8766f7185040d8b8b69402.tar.gz",
|
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/299f44bbdf679def53882c7c45dbadd20f750acd.tar.gz",
|
||||||
.hash = "v8-0.0.0-xddH69zDAwD5i0hGhAsv3SPeihlj5fXGpJyO15KqBWOn",
|
.hash = "v8-0.0.0-xddH6xHEAwCo_OGkWshjXdYHGk18oSG3XZPYtf4tvF0P",
|
||||||
},
|
},
|
||||||
//.v8 = .{ .path = "../zig-v8-fork" }
|
//.v8 = .{ .path = "../zig-v8-fork" }
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
|||||||
|
|
||||||
// This is the callback that runs whenever a module is dynamically imported.
|
// This is the callback that runs whenever a module is dynamically imported.
|
||||||
isolate.setHostImportModuleDynamicallyCallback(JsContext.dynamicModuleCallback);
|
isolate.setHostImportModuleDynamicallyCallback(JsContext.dynamicModuleCallback);
|
||||||
|
isolate.setPromiseRejectCallback(promiseRejectCallback);
|
||||||
|
|
||||||
isolate.enter();
|
isolate.enter();
|
||||||
errdefer isolate.exit();
|
errdefer isolate.exit();
|
||||||
@@ -328,6 +329,20 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
|||||||
self.isolate.lowMemoryNotification();
|
self.isolate.lowMemoryNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn promiseRejectCallback(v8_msg: v8.C_PromiseRejectMessage) callconv(.c) void {
|
||||||
|
const msg = v8.PromiseRejectMessage.initFromC(v8_msg);
|
||||||
|
const isolate = msg.getPromise().toObject().getIsolate();
|
||||||
|
const v8_context = isolate.getCurrentContext();
|
||||||
|
const context: *JsContext = @ptrFromInt(v8_context.getEmbedderData(1).castTo(v8.BigInt).getUint64());
|
||||||
|
|
||||||
|
const value =
|
||||||
|
if (msg.getValue()) |v8_value| valueToString(context.call_arena, v8_value, isolate, v8_context) catch |err| @errorName(err)
|
||||||
|
else "no value";
|
||||||
|
|
||||||
|
log.debug(.js, "unhandled rejection", .{.value =value});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ExecutionWorld closely models a JS World.
|
// ExecutionWorld closely models a JS World.
|
||||||
// https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/bindings/core/v8/V8BindingDesign.md#World
|
// https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/bindings/core/v8/V8BindingDesign.md#World
|
||||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/ExecutionWorld
|
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/ExecutionWorld
|
||||||
|
|||||||
Reference in New Issue
Block a user