Skip to content

fix(context): skip workers without a session and raise a clear error from Target#worker - #669

Merged
route merged 1 commit into
mainfrom
fix/workers-without-session
Oct 21, 2026
Merged

route merged 1 commit into
mainfrom
fix/workers-without-session

Conversation

@route

@route route commented Oct 21, 2026

Copy link
Copy Markdown
Member

A worker target without a session, such as a service worker Ferrum detached from or a worker whose session was detached, broke Context#workers and Target#worker. Target#worker built a Worker on session(nil) and failed with CDP's "Message may have string 'sessionId' property", and Context#workers listed dead workers or raised the same error.

Fix

  • Context#workers skips worker and shared worker targets without a session. Since fix(context): reuse the session of an attached target in attach_target #668 the session id is cleared on detach, so this covers detached workers.
  • Target#worker raises NoSuchTargetError when there's no session, pointing to Context#attach_target. Only in flatten mode, the non-flatten one connects by target id.

Test

spec/worker_spec.rb:

  • A dedicated worker detached through the page session drops out of browser.workers. Without the fix it stays listed.
  • target.worker on a service worker Ferrum detached from raises NoSuchTargetError. Without the fix it raises the CDP error.

@route
route merged commit 259d2f1 into main Oct 21, 2026
9 of 10 checks passed
@route
route deleted the fix/workers-without-session branch October 21, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant