on XHR shutdown, use terminate to prevent any client callbacks into the XHR

This commit is contained in:
Karl Seguin
2026-01-21 14:46:34 +08:00
parent 81378d4353
commit 97f9c2991b
2 changed files with 8 additions and 1 deletions

View File

@@ -93,7 +93,7 @@ pub fn init(page: *Page) !*XMLHttpRequest {
pub fn deinit(self: *XMLHttpRequest) void {
if (self._transfer) |transfer| {
transfer.abort(error.Abort);
transfer.terminate();
self._transfer = null;
}
self._page.releaseArena(self._arena);

View File

@@ -979,6 +979,13 @@ pub const Transfer = struct {
self.deinit();
}
pub fn terminate(self: *Transfer) void {
if (self._handle != null) {
self.client.endTransfer(self);
}
self.deinit();
}
// internal, when the page is shutting down. Doesn't have the same ceremony
// as abort (doesn't send a notification, doesn't invoke an error callback)
fn kill(self: *Transfer) void {