From f11ab2f145299374ea12726b35f260f2a4d084e4 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 25 Jun 2024 19:05:32 +0200 Subject: [PATCH] chore: enable keepAlive in happy eyeballs http.Agent (#31434) --- packages/playwright-core/src/utils/happy-eyeballs.ts | 5 +++-- tests/library/browsercontext-fetch.spec.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/playwright-core/src/utils/happy-eyeballs.ts b/packages/playwright-core/src/utils/happy-eyeballs.ts index 4576da7899..37d5c1b271 100644 --- a/packages/playwright-core/src/utils/happy-eyeballs.ts +++ b/packages/playwright-core/src/utils/happy-eyeballs.ts @@ -45,8 +45,9 @@ class HttpsHappyEyeballsAgent extends https.Agent { } } -export const httpsHappyEyeballsAgent = new HttpsHappyEyeballsAgent(); -export const httpHappyEyeballsAgent = new HttpHappyEyeballsAgent(); +// These options are aligned with the default Node.js globalAgent options. +export const httpsHappyEyeballsAgent = new HttpsHappyEyeballsAgent({ keepAlive: true }); +export const httpHappyEyeballsAgent = new HttpHappyEyeballsAgent({ keepAlive: true }); export async function createSocket(host: string, port: number): Promise { return new Promise((resolve, reject) => { diff --git a/tests/library/browsercontext-fetch.spec.ts b/tests/library/browsercontext-fetch.spec.ts index 550cc56d74..f8c0327c7d 100644 --- a/tests/library/browsercontext-fetch.spec.ts +++ b/tests/library/browsercontext-fetch.spec.ts @@ -853,7 +853,7 @@ it('should not hang on a brotli encoded Range request', async ({ context, server headers: { range: 'bytes=0-2', }, - })).rejects.toThrow(/(failed to decompress 'br' encoding: Error: unexpected end of file|Parse Error: Data after \`Connection: close\`)/); + })).rejects.toThrow(/Parse Error: Expected HTTP/); }); it('should dispose', async function({ context, server }) {