Redo napi cleanup hooks (#13487)

This commit is contained in:
Jarred Sumner
2024-08-23 21:09:56 -07:00
committed by GitHub
parent e97c65fd1e
commit b53c25e5f8
3 changed files with 24 additions and 36 deletions

View File

@@ -1304,11 +1304,11 @@ pub const VirtualMachine = struct {
this.exit_handler.dispatchOnExit();
const rare_data = this.rare_data orelse return;
var hook = rare_data.cleanup_hook orelse return;
hook.execute();
while (hook.next) |next| {
next.execute();
hook = next;
var hooks = rare_data.cleanup_hooks;
defer if (!is_main_thread_vm) hooks.clearAndFree(bun.default_allocator);
rare_data.cleanup_hooks = .{};
for (hooks.items) |hook| {
hook.execute();
}
}