Skip to content

Commit 1da0ec6

Browse files
aspiersclaude
andcommitted
fix(e2e): drain fetch response bodies in CSP nonce step
Under Node's fetch/undici, an un-drained response body keeps the socket open and can leave open-handles after the test exits. The nonce-freshness check added a second fetch (and a 404-fallback third) without consuming either body. Drain each response via .text() before moving on, matching the pattern in captureGet(). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 2ceaded commit 1da0ec6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

e2e/step-definitions/security.steps.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,16 @@ Then(
212212
const firstCsp = headers.get('content-security-policy') ?? ''
213213
const firstNonce = extractScriptSrcNonce(firstCsp)
214214

215+
// Under Node's fetch/undici, an un-drained response body keeps the
216+
// socket open and can leave open-handles after the test exits. Drain
217+
// each response's body (via .text()) before moving on, matching the
218+
// pattern in captureGet() above.
215219
const previewUrl = `${testEnv.authUrl}/preview/login`
216220
let second = await fetch(previewUrl, { redirect: 'manual' })
221+
await second.text()
217222
if (second.status === 404) {
218223
second = await fetch(`${testEnv.authUrl}/health`, { redirect: 'manual' })
224+
await second.text()
219225
}
220226
const secondCsp = second.headers.get('content-security-policy') ?? ''
221227
const secondNonce = extractScriptSrcNonce(secondCsp)

0 commit comments

Comments
 (0)