Skip to main content

Module crash

Module crash 

Source
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}. Requires Target.setDiscoverTargets({discover:true}) on the connection.
  • Inspector.targetCrashed — per-attached-session event (no params). Requires Inspector.enable on 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 matches target_id (browser-level Target.targetCrashed) or session_id (per-session Inspector.targetCrashed). On a matching crash event, return SessionError::TabCrashed instead of waiting for the request to time out.