Skip to content

Commit

Permalink
LibWeb: Visit the MessagePort's associated Worker target
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit eeee6ba3f54bc920e7cd493820faab943b59e0bd)
  • Loading branch information
trflynn89 authored and nico committed Nov 21, 2024
1 parent 94af884 commit 68e58b5
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions Userland/Libraries/LibWeb/HTML/MessagePort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 68e58b5

Please sign in to comment.