From eeee6ba3f54bc920e7cd493820faab943b59e0bd Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 16 Oct 2024 19:51:05 -0400 Subject: [PATCH] LibWeb: Visit the MessagePort's associated Worker target Without this, a worker can be GC'd in a very simple script such as: const worker = new Worker("script.js"); worker.onmessage = () => {}; Where script.js attempts to post a message back to the parent window. When the Worker is GC'd, the IPC connection from the WebContent process to the WebWorker process is closed. When this occurs, the WebWorker will exit() from LibIPC, and any message from the worker to its parent does not have a chance to run. --- Userland/Libraries/LibWeb/HTML/MessagePort.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp index 283bb036e2c..90ec66b0af2 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp @@ -68,10 +68,7 @@ void MessagePort::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_remote_port); - - // FIXME: This is incorrect!! We *should* be visiting the worker event target, - // but CI hangs if we do: https://github.com/SerenityOS/serenity/issues/23899 - visitor.ignore(m_worker_event_target); + visitor.visit(m_worker_event_target); } void MessagePort::set_worker_event_target(JS::NonnullGCPtr target)