Skip to content
Back to Blog
Cypress

The changelog said fixed. It wasn't: bisecting a Windows-only Cypress 16 hang

Cypress 16 froze at login on Windows and never on WSL. A changelog fix that wasn't ours sent me the wrong way, then a fake app, a fake identity provider and a bisect pinned it to a 4 MB script that Cypress rewrites.

The changelog said fixed. It wasn't: bisecting a Windows-only Cypress 16 hang
100% Human-Authored: All engineering insights, production war stories, and code were written by Marcelo Costa with zero AI involvement in authoring. AI was used solely for multilingual translations.

At the end of October I deleted a workaround from our Cypress config because a changelog told me to. I opened the PR, asked my colleagues on Windows for one run, and the same day they were stuck at login again.

The symptom hadn't changed since September: open the suite on Windows and the run sits on the login page. Forever. No error, no timeout, pageLoadTimeout never fires, the process never exits. Run the same spec from WSL and it's green. Every single time.

So this is the story of a two-month hang, three wrong suspects, and the bisect that finally pinned it to one combination: a script of 4 MB or more, rewritten by Cypress. Login had nothing to do with it.

Stuck at login, only on Windows

It started in mid-September, on the branch that moved us to Cypress 16 (I wrote about how that migration went before). Colleagues on Windows 11 laptops, PowerShell, Chrome. The runner opened, the first test started, and the identity provider's sign-in page just sat there. Restart, switch browser, and sometimes it worked. WSL never reproduced it once.

Why the login page? Because login is the first thing every test does: the first cy.visit('/') of each spec lives inside our login command. Whatever freezes first freezes on the sign-in page. That one detail made everyone (me included) stare at authentication for weeks.

The quick suspects went first. Enterprise cookie policies? A colleague's chrome://policy export had nothing relevant. Node version? A wrong one gives a hard error, not a silent hang. Next.

Suspect one: bundle size

Cypress 16 moved Chrome, Chromium and Edge to a native browser network path (Electron and Firefox keep the old proxy). And there was an open issue, #34794: on that path, spec bundles of roughly 26 MB and up never arrived, and the run hung without a timeout. Exactly our symptom.

Except our biggest bundle was 15 MB.

Here's the part I'm not proud of. I convinced myself the threshold moved with hardware: a fast WSL box squeezes through, a corporate laptop stalls. Sounded plausible, but I was wrong.

Still, inline source maps were about 60% of that 15 MB, so slimming them looked like free money. Which is where I found the side lesson of this whole saga:

// webpack.config.js (IGNORED)
devtool: 'source-map',

@cypress/webpack-preprocessor overwrites devtool with 'inline-source-map' for any value except a literal false. 'source-map', 'eval', whatever you pick: silently replaced. The only way out is to switch it off and add the plugin yourself:

// webpack.config.js (CORRECT)
devtool: false,
plugins: [
  new webpack.SourceMapDevToolPlugin({ noSources: true }),
],

noSources drops only the embedded TypeScript text. The mappings stay identical, so runner stack traces still point at app/**.ts:line:col; you just can't read the original source in DevTools anymore. Basically, the support bundle went from 14.6 MB → 7.5 MB and the biggest spec from 5.7 → 3.4 MB, for free.

The next day a colleague ran headless on Windows with the slim bundles. Hung.

So the real fix that week was the escape hatch Cypress ships next to the native path: forceHttp1, which routes traffic through the legacy proxy. We forced it on every Windows run:

// config/force-http1.ts
import * as os from 'os';

export function shouldForceHttp1(config: Cypress.PluginConfigOptions): boolean {
  const isWsl = process.platform === 'linux' && /microsoft/i.test(os.release());
  return config.forceHttp1 || process.platform === 'win32' || (config.isInteractive && !isWsl);
}
// setupNodeEvents
config.forceHttp1 = shouldForceHttp1(config);
Windows, any mode         → forceHttp1 (legacy proxy)
cypress open, not WSL     → forceHttp1 (legacy proxy)
Linux / WSL, cypress run  → native network path

Cypress prints a deprecation warning every time it resolves to true (the option arrived already deprecated), and that's fine. The warning is also how you tell which path a run took.

The changelog said fixed

End of October, Cypress 16.2.1 shipped with a changelog line saying forceHttp1 was no longer needed for the large-bundle hang. I bumped the version, deleted force-http1.ts, removed the call from every config. Typecheck green. I wrote down "pending: one Windows run to confirm", opened the PR and asked my Windows colleagues to give it a go.

Same day: Windows colleagues on 16.2.1, no forceHttp1. Stuck at login. In open mode the app even rendered outside the runner's view.

Then I read the fix itself, PR #35059, instead of the changelog line about it. It fixed bundles over ~75 MB, the ones that blew past the old 100 MiB limit on a single CDP message. A size limit, so nothing to do with hardware (there goes my theory). And our 7.5 MB bundles never came anywhere near it.

The bug that fix closed was never our bug. Ours was a different native-path bug all along, hiding behind a similar symptom.

The workaround came back the same day, restored verbatim from git history, and this time with a rule written next to it in the repo: force-http1.ts goes away only after one Windows open-mode run and one Windows headless run pass on the native path. A changelog doesn't count as a run.

The screenshot from that day didn't help much either: command log stuck on session [...] creating, the sign-in page fully rendered, every request a 200. Not a network block, not a framing block. Another login-shaped dead end.

Building the bug outside the company

I can't attach the app I test at the company I work for to a public issue. So I built a fake one.

Two local servers, two origins, no external services:

Origin Role
https://localhost:3000 The app. An 8 MB main.js full of window.top / window.location references (so Cypress rewrites it), plus 6 chunk scripts. No token, redirect to the IdP.
https://127.0.0.1:4000 A fake OIDC identity provider. Two-step AJAX sign-in form, X-Frame-Options: DENY, frame-ancestors 'self', Cross-Origin-Embedder-Policy: require-corp.

The Cypress side mirrors our real config: chromeWebSecurity: false, numTestsKeptInMemory: 1, cy.session() with cacheAcrossSpecs and a validate that reads cy.getAllSessionStorage() (I've written about validate functions that can't fail before; this one could). 15 specs × 3 tests. Funny thing: #34969 describes that exact combination, Windows 11 Enterprise included. Someone else had been staring at my config.

And it reproduced:

  • native path → 10 of 10 runs hung on the very first test
  • forceHttp1 → all 45 tests passed in 11 of 12 runs. The twelfth was a bug in my fake app (the callback page loaded twice and the reused code overwrote the token). Yes, the repro had a flaky test of its own. Of course it did.

Two things bit me on the way, both very Windows:

  • Start-Process -RedirectStandardError lost the first line of every DEBUG entry, which is exactly the line with the namespace and the timestamp. Redirecting through cmd.exe /c kept them.
  • Closing the PowerShell window mid-run left server.js orphaned on ports 3000 and 4000, so the next run died on a busy port. The scripts now stop orphaned servers before they start.

Bisect, one step at a time

A full login flow has too many moving parts to blame. So I split it into five specs, each one going a step further than the previous, run one at a time with no global login:

01  static page on the app origin        → PASS
02  app bundle, no login at all          → HANG
03  IdP sign-in page, visited directly   → PASS
04  login without cy.session
05  login inside cy.session

Spec 02 is three lines:

// cypress/bisect/02-visit-app-bundle.cy.js
it('visits the app with its 8 MB bundle and chunks, no login', () => {
  cy.intercept({ method: 'GET', url: '**/chunk-*.js*' }, { log: false });
  cy.visit('/?noauth=1');
  cy.get('body[data-ready="1"]').should('exist');
});

No cy.session, no identity provider, no cross-origin anything. Still hung. All that time staring at the login page, and login wasn't even in the room.

DEBUG=cypress:* showed exactly where it stopped (4 MB run, trimmed):

14:34:53.961Z cdp-fetch-transport response pause for https://localhost:3000/main.js: status 200
14:35:03.970Z cri-client command Fetch.getResponseBody ... has not resolved after 10000ms
14:35:12.944Z cdp-connection terminal disconnect for target ... (reconnection disabled)
14:35:12.945Z cdp-fetch-transport CDP Fetch send failed: Fetch.continueResponse will not run as the CRI connection ... has been closed

In plain words:

Cypress pauses main.js so it can rewrite it
  → asks Chrome for the body (Fetch.getResponseBody)
  → no answer after 10 s
  → ~19 s after the pause, the CDP connection to the page drops, reconnection disabled
  → main.js stays paused forever, pageLoadTimeout never fires

For comparison, a healthy 2 MB run goes from response pause to resolved in 29 ms.

Now, here is where the plot thickens 🕵️

Same spec, one variable at a time:

Network mode Server main.js Runs Result
native TLS + HTTP/2 8 MB 14 all hung
native TLS + HTTP/1.1 only 8 MB 2 all hung
native plain HTTP/1.1 8 MB 4 3 hung, 1 passed
native TLS + HTTP/2 4 MB 2 all hung
native TLS + HTTP/2 2 MB 6 all passed
native TLS + HTTP/2 1 MB 2 all passed
native, modifyObstructiveCode: false TLS + HTTP/2 8 MB 2 all passed
forceHttp1: true TLS + HTTP/2 8 MB 15 none hung

The 8 MB rows include the full-flow runs. The smaller rows are 2 to 6 runs each, so read them as strong hints, not statistics.

Three things fall out of that table:

1. Size matters, but the threshold is small. 2 MB passed every time, 4 MB hung every time. Nowhere near 26 MB, nowhere near 75 MB.

2. It's not TLS, and it's not HTTP/2. HTTPS forced down to HTTP/1.1 still hangs, and so does plain HTTP/1.1 with no encryption at all: 3 of 4 runs. My first plain run passed, and "TLS is the factor" went straight into my draft of the issue comment. The next three plain runs hung. One green run is not proof.

3. The rewrite is the trigger. With modifyObstructiveCode: false, Cypress stops rewriting scripts, never asks Chrome for the body, and the hang is gone.

So it was never login, never sessions, and never the spec bundle I had slimmed. It was the app's own JavaScript, which Cypress rewrites on every page load: 34 files and about 11 MB uncompressed at startup, and exactly one of them over the line, a single 5 MB chunk. Everything else is 2.4 MB or less.

The closest upstream match is #35205: same getResponseBody → terminal disconnect sequence, but the contributor needed a 150 MiB synthetic payload to trigger it. On my Windows 11 Enterprise laptop (Cypress 16.3.0, Chrome 157, Node 24), 4 MB was enough, deterministically. The repro, the table and both logs are in my comment there, with a pointer from #34969. The repo is here: .\bisect.ps1 -Only 02 is the smallest case.

If it's hitting you

1. Force HTTP/1 where it hangs. forceHttp1: true, scoped to the platforms that need it (the helper above), so Linux CI keeps the native path. Deprecated, prints a warning, works. Quick stopgap without touching config: --browser electron, which uses the legacy proxy anyway.

2. Or stop the rewrite, if your app allows it. modifyObstructiveCode: false passed in the repro. The trade-off: Cypress stops neutralising frame-busting code, so an app that checks window.top !== window.self may break out of the runner. I haven't moved our real suite to it; forceHttp1 stays.

3. Remove a workaround with a run, not with a changelog. Read the fix, check whether its numbers match yours, then run on the platform that broke. One open-mode run, one headless run. Here, one run on the PR caught it the same day I opened it.

Our force-http1.ts is still there, by the way. It goes away the day a Windows laptop runs the native path green, not a day before.