Browse Source

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.
Timothy Flynn 8 months ago
parent
commit
eeee6ba3f5
1 changed files with 1 additions and 4 deletions
  1. 1 4
      Userland/Libraries/LibWeb/HTML/MessagePort.cpp

+ 1 - 4
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<DOM::EventTarget> target)