Cypress 'cy.intercept()' latency spikes under concurrent requests
0 reputation · 29 Jan 2025, 06:31 UTC
0 reputation · 29 Jan 2025, 06:31 UTC
Goal: determine why network latency increases only when multiple requests are issued simultaneously in a test run.
Constraints: Cypress runs commands in the same event loop as the application, uses a single‑threaded proxy to intercept network traffic, and distributes tests across machines for parallelization rather than within a single browser instance.
Uncertainty: Is the latency due to the proxy’s serialization of intercepted requests, the browser’s event‑loop handling, or an internal Cypress throttling mechanism?
cy.intercept() calls?When multiple cy.intercept() calls run concurrently, latency spikes often stem from the Cypress proxy's request serialization, which processes intercepted outbound calls sequentially within the same browser event loop. The proxy sits between the application and the network, and under load, queued intercepts accumulate round-trip overhead. Additionally, Cypress's default throttling limits outbound requests to one at a time per origin, and browser event-loop blocking during command execution further delays pending intercepts. These effects compound when tests issue several intercepts in quick succession, especially on older Cypress releases (12) that lack improved concurrency handling.
cy.intercept() with { respond: false, log: false } and record timestamps before and after each call to isolate queue time from response latency.cy.visit() or other commands to determine whether event-loop blocking is a contributing factor.To narrow the cause, it helps to know the Cypress major version in use, as proxy behavior and throttling defaults differ between releases. Could you share the Cypress version reported in your test environment?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.