mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 04:49:06 +00:00
Raise error on unhandled rejected promises (#1010)
* deal with unhandled rejected promise * use Vector<Strong<JSPromise>> to store rejected promises
This commit is contained in:
@@ -272,6 +272,7 @@ comptime {
|
||||
_ = Bun__getVM;
|
||||
_ = Bun__drainMicrotasks;
|
||||
_ = Bun__queueMicrotask;
|
||||
_ = Bun__handleRejectedPromise;
|
||||
_ = Bun__readOriginTimer;
|
||||
}
|
||||
}
|
||||
@@ -280,6 +281,11 @@ pub export fn Bun__queueMicrotask(global: *JSGlobalObject, task: *JSC.CppTask) v
|
||||
global.bunVM().eventLoop().enqueueTask(Task.init(task));
|
||||
}
|
||||
|
||||
pub export fn Bun__handleRejectedPromise(global: *JSGlobalObject, promise: *JSC.JSPromise) void {
|
||||
const result = promise.result(global.vm());
|
||||
global.bunVM().runErrorHandler(result, null);
|
||||
}
|
||||
|
||||
// If you read JavascriptCore/API/JSVirtualMachine.mm - https://github.com/WebKit/WebKit/blob/acff93fb303baa670c055cb24c2bad08691a01a0/Source/JavaScriptCore/API/JSVirtualMachine.mm#L101
|
||||
// We can see that it's sort of like std.mem.Allocator but for JSGlobalContextRef, to support Automatic Reference Counting
|
||||
// Its unavailable on Linux
|
||||
|
||||
Reference in New Issue
Block a user