Skip to content

feat(events): run on(:request), on(:auth) and on(:dialog) callbacks as a chain - #703

Merged
route merged 1 commit into
mainfrom
feat/event-chains
Nov 15, 2026
Merged

route merged 1 commit into
mainfrom
feat/event-chains

Conversation

@route

@route route commented Nov 15, 2026

Copy link
Copy Markdown
Member

Replaces the (object, index, total) callback shape with a chain of responsibility. Supersedes #701.

  • Callbacks run in the order they were added and the rest are skipped once one handles the object: continue, respond or abort for a request, continue or abort for an auth challenge, accept or dismiss for a dialog. A callback that doesn't care just returns.
  • An object nobody handled gets a default: a request is continued, an auth challenge gets Chrome's default response, a dialog is accepted with a warning.
  • Callbacks receive only the object. page.on(:request, &:continue) works now, it used to call continue(index, total).
  • InterceptedRequest#handled?, AuthRequest#handled? and Dialog#handled? tell whether a previous callback took the object.
  • Network#authorize and the proxy authorization no longer count callbacks to decide what to do.

Breaking:

  • index and total are nil for blocks that still take them, a lambda taking three arguments raises.
  • A callback that holds a request to answer later gets it continued.
  • A callback registered after the handler no longer sees that request.
  • Raw CDP events keep yielding (params, index, total).

…s a chain

Callbacks run in the order they were added and stop at the first one that handles the object (continue, respond, abort, accept, dismiss), so a callback that doesn't care just returns. An object nobody handled is continued, an auth challenge gets Chrome's default response, and a dialog is accepted with a warning. Callbacks receive only the object, not index and total, which also makes page.on(:request, &:continue) work. InterceptedRequest, AuthRequest and Dialog get handled?.
@route
route merged commit f1cd5cb into main Nov 15, 2026
7 checks passed
@route
route deleted the feat/event-chains branch November 15, 2026 10:31
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