From 940fa4fd4e982828f0878ba320e8807b3fcd8783 Mon Sep 17 00:00:00 2001 From: Alistair Smith Date: Tue, 27 May 2025 15:45:34 -0700 Subject: [PATCH] rm --- src/bun.js/web_worker.zig | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/src/bun.js/web_worker.zig b/src/bun.js/web_worker.zig index b30acdb1c1..b8fea6e31b 100644 --- a/src/bun.js/web_worker.zig +++ b/src/bun.js/web_worker.zig @@ -78,9 +78,6 @@ export fn WebWorker__updatePtr(worker: *WebWorker, ptr: *anyopaque) bool { startWithErrorHandling, .{worker}, ) catch { - log("[{d}] WebWorker__updatePtr - failed to spawn thread, dispatching exit", .{worker.execution_context_id}); - worker.setStatus(.terminated); - WebWorker__dispatchExit(null, worker.cpp_worker, 1); worker.deinit(); return false; }; @@ -444,13 +441,6 @@ fn spin(this: *WebWorker) void { log("[{d}] spin start", .{this.execution_context_id}); var vm = this.vm.?; - - // did we terminate before even starting ? - if (this.hasRequestedTerminate() or this.status.load(.acquire) == .terminated) { - log("[{d}] spin - terminated before start", .{this.execution_context_id}); - return; - } - assert(this.status.load(.acquire) == .start); this.setStatus(.starting); vm.preload = this.preloads; @@ -570,30 +560,6 @@ pub fn notifyNeedTermination(this: *WebWorker) callconv(.c) void { } log("[{d}] notifyNeedTermination", .{this.execution_context_id}); - const current_status = this.status.load(.acquire); - - // If the worker hasn't started yet or is still starting, we need to handle termination differently - // This can happen when: - // 1. terminate() is called immediately after creating the worker - // 2. The worker thread hasn't been spawned yet - // 3. The worker thread is spawned but hasn't reached the event loop - // In these cases, we need to dispatch the exit event immediately because the worker - // thread might not be able to do it itself. - if (current_status == .start or current_status == .starting) { - log("[{d}] notifyNeedTermination - worker not fully started, dispatching exit immediately", .{this.execution_context_id}); - - this.setStatus(.terminated); - - // Dispatch the exit event immediately since the worker thread might not be running yet - // or might not have reached the event loop - WebWorker__dispatchExit(null, this.cpp_worker, 0); - this.parent_poll_ref.unrefConcurrently(this.parent); - - if (this.vm) |vm| vm.eventLoop().wakeup(); - - return; - } - if (this.vm) |vm| { vm.eventLoop().wakeup(); // TODO(@190n) notifyNeedTermination