Clear identity before forcing finalizers

We need to remove v8 finalizer callbacks upfront so that, as we tear things down
there's no chance for v8 to try to finalize something which has already been
finalized or is gone.
This commit is contained in:
Karl Seguin
2026-04-07 21:51:38 +08:00
parent 3b3917321b
commit def713db15

View File

@@ -236,6 +236,9 @@ pub fn releaseOrigin(self: *Session, origin: *js.Origin) void {
/// Reset page_arena and factory for a clean slate.
/// Called when root page is removed.
fn resetPageResources(self: *Session) void {
self.identity.deinit();
self.identity = .{};
// Force cleanup all remaining finalized objects
{
var it = self.finalizer_callbacks.valueIterator();
@@ -260,9 +263,6 @@ fn resetPageResources(self: *Session) void {
self.temps = .empty;
}
self.identity.deinit();
self.identity = .{};
if (comptime IS_DEBUG) {
std.debug.assert(self.origins.count() == 0);
}