Skip to content

ref(events): yield only the params to raw CDP event callbacks - #710

Merged
route merged 2 commits into
mainfrom
fix/raw-event-yields-params
Nov 20, 2026
Merged

route merged 2 commits into
mainfrom
fix/raw-event-yields-params

Conversation

@route

@route route commented Nov 20, 2026

Copy link
Copy Markdown
Member

Problem

page.on("Some.cdpEvent") { |params, index, total| } yielded the callback's index among the event's subscribers and their total number. That's dispatcher internals leaking into the public API, and it broke one-argument lambdas and symbol procs: page.on("Runtime.consoleAPICalled", &->(params) { ... }) raised ArgumentError, which the dispatcher swallowed, so the callback silently never ran. :request, :auth and :dialog already yield only the object.

Change

Concurrency::Dispatcher calls each callback with the payload only, so raw CDP events yield just the params.

Tracing was the only internal user of the index: it ignored Tracing.tracingComplete unless its callback was the first one registered. A user subscription added before the first record therefore made record time out. The check is gone; Tracing already subscribes once per page.

Breaking

Raw CDP event callbacks no longer receive index and total. Listed under Changed in the changelog.

Specs

  • A one-argument lambda subscribed to a raw CDP event receives the params.
  • tracing.record returns the trace when Tracing.tracingComplete already has a subscriber.

Both fail without the change and pass with it.

The dispatcher passed each callback its index and the total number of callbacks, leaking subscriber internals into on and breaking lambdas and symbol procs taking one argument. Tracing relied on the index and ignored Tracing.tracingComplete unless its callback came first, so a user subscription added before the first record made it time out.
@route
route merged commit d225ffc into main Nov 20, 2026
11 of 12 checks passed
@route
route deleted the fix/raw-event-yields-params branch November 20, 2026 07:50
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