mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
Handle exceptions in NAPI finalizers as uncaught exceptions
This commit is contained in:
@@ -11,7 +11,7 @@ void NapiFinalizer::call(napi_env env, void* data)
|
||||
{
|
||||
if (m_callback) {
|
||||
NAPI_LOG_CURRENT_FUNCTION;
|
||||
napi_enqueue_finalizer(env, this->m_callback, data, this->m_hint);
|
||||
napi_enqueue_finalizer(env, m_callback, data, m_hint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1434,11 +1434,14 @@ pub const Finalizer = struct {
|
||||
pub const Queue = std.fifo.LinearFifo(Finalizer, .Dynamic);
|
||||
|
||||
pub fn drain(this: *Finalizer.Queue) void {
|
||||
while (this.readItem()) |*finalizer| {
|
||||
while (this.readItem()) |finalizer| {
|
||||
const env = finalizer.env.?;
|
||||
const handle_scope = NapiHandleScope.open(env, false);
|
||||
defer if (handle_scope) |scope| scope.close(env);
|
||||
finalizer.fun.?(env, finalizer.data, finalizer.hint);
|
||||
if (env.toJS().tryTakeException()) |exception| {
|
||||
_ = env.toJS().bunVM().uncaughtException(env.toJS(), exception, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user