Skip to content

Set-Cookie from service worker responses does not reach cookie middleware when the proxy is disabled #34568

Description

@AtofStryker

Part of the proxy-disabled / HTTP/2 pipeline work. Follow-up to #34555 / #34566, raised by Cursor Bugbot in review. Low priority — see Impact.

What & why

With CYPRESS_INTERNAL_DISABLE_PROXY=1, responses fetched on a service worker's CDP session run the middleware onion but arrive with no Set-Cookie, so cookie simulation never applies. Set-Cookie only travels on Network.responseReceivedExtraInfo (#34327), never on a Fetch pause, and CDPNetworkExtraInfo correlates those by ${sessionId}:${requestId} on the page connection — where Network is deliberately not enabled for service_worker targets. So no entry ever exists for a SW-session pause. MITM parity drift: the proxy does see service worker wire fetches.

Impact — why this is low priority

With the proxy disabled there is no server-side cookie jar; the browser is the source of truth. The only consumer of Set-Cookie on that path is simulated-top rewriting — applying cookies as though the AUT were top-level rather than iframed — and a service worker has no document and no top-level browsing context, so that has little meaning for its fetches.

The one case that could matter is a worker handling a document navigation, since that response becomes the AUT document in a frame; instrumenting the driver spec showed 14 such navigations among the 58 SW-session pauses. Nothing regresses by deferring — before #34555, service worker traffic ran no middleware at all.

Do not re-try: awaiting Network.enable deadlocks

CriClient._onAttachedToTarget awaits the onServiceWorkerTargetAttached hook before Runtime.runIfWaitingForDebugger, and CDP does not answer Network.enable on a target still paused for the debugger — so the worker is never released. service-worker.cy.js drops 28/28 → 0 passing on Chrome and Electron, and service_worker_spec.js regresses too. It is the await, not the ordering: Fetch.enable is answered while paused, which is the only reason the current code works. Un-awaited works but lands after the worker starts, so the earliest pauses still miss extraInfo.

Options

  1. Preferred: send Network.enable un-awaited, keep the promise, and have the transport await it before extraInfo lookups on that session. Fetch interception is installed before the worker is released, so nothing escapes while we wait — this blocks a request briefly rather than the debugger.
  2. Have CDPNetworkExtraInfo observe the browser connection, where Network is already enabled for SW targets, joining via targetInfo.targetId. Risk: CDP request ids are per-session, so the same request may not share an id across connections.
  3. Accept the drift and record it in the proxy-disabled behavior-changes log.

Acceptance criteria

Nothing detects this today, so the fixture is really the deliverable that decides whether 1–2 are worth building.

  • A fixture (service worker proxying a Set-Cookie response, asserting the simulated-top rewrite) fails without the fix and passes with it — or shows the case is unreachable, and the drift is documented instead
  • service-worker.cy.js stays 28/28 proxy-off on Chrome and Electron, no wall-clock regression
  • service_worker_spec.js / service_worker_protocol_spec.js stay green proxy-off
  • MITM behavior unchanged

system-tests-electron-cdp-remediated carries no service-worker specs — worth closing while here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HTTP/2estimate-readyThis issue has enough information to be estimated by AI

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions