Expand description
CDP renderer-crash detection.
Background: the recover-once wrappers (with_scratch_recovery,
with_named_tab_recovery, bare-fetch recovery) classify
SessionError::TabCrashed as recoverable — but until this module, no
code path actually constructed that variant. The protocol-error
classifier converts post-mortem “no target with given id” responses
into TargetGone, which is fine for the next call but means an
in-flight Runtime.evaluate against a crashing renderer only ever
surfaces as TabHung after the timeout expires.
This module fills the gap: while a CDP evaluate is in flight, watch
the event stream for the renderer-crash signal and short-circuit the
in-flight call with a typed TabCrashed immediately. The two
observable crash signals are:
Target.targetCrashed— browser-level event with{targetId, status, errorCode}. RequiresTarget.setDiscoverTargets({discover:true})on the connection.Inspector.targetCrashed— per-attached-session event (no params). RequiresInspector.enableon the attached session.
We listen for both and match on session_id (Inspector) or
targetId (Target). BiDi has no equivalent protocol event — there,
a context crash surfaces as no such frame/context on the next
request, which the TargetGone classifier already handles.
Functions§
- evaluate_
with_ crash_ detection - Run
fut(a CDP request) while watching the client’s event stream for a renderer-crash signal that matchestarget_id(browser-levelTarget.targetCrashed) orsession_id(per-sessionInspector.targetCrashed). On a matching crash event, returnSessionError::TabCrashedinstead of waiting for the request to time out.