From 62a1f40c7e6e7eb42df7eecc8891d63c37ff6c02 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Thu, 4 Jun 2026 21:49:48 +0000 Subject: [PATCH 1/2] fix: avoid test timeout in extractZipArchive by batching writes The 'it can extract a larger zip' test wrote 5000+ individual lines via separate async fs operations, which could exceed the 30s test timeout on slow CI runners (observed on Node 24). Build the entire zip content in memory as a single Buffer and write it in one operation instead. --- src/utils/__tests__/system.test.ts | 41 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/utils/__tests__/system.test.ts b/src/utils/__tests__/system.test.ts index d792e84f..9dfbf9ce 100644 --- a/src/utils/__tests__/system.test.ts +++ b/src/utils/__tests__/system.test.ts @@ -254,30 +254,29 @@ describe('extractZipArchive', () => { await withTempDir(async tmpdir => { const zip = `${tmpdir}/out.zip`; - const zipf = await fs.promises.open(zip, 'w'); - await zipf.writeFile( - Buffer.from([ - 80, 75, 3, 4, 10, 0, 0, 0, 0, 0, 99, 150, 109, 88, 220, 199, 60, 159, - 40, 11, 4, 0, 40, 11, 4, 0, 5, 0, 28, 0, 116, 46, 116, 120, 116, 85, - 84, 9, 0, 3, 153, 245, 241, 101, 140, 245, 241, 101, 117, 120, 11, 0, - 1, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, - ]), + // Build the entire zip content in memory to avoid 5000+ individual async + // writes which can exceed the test timeout on slow CI runners. + const header = Buffer.from([ + 80, 75, 3, 4, 10, 0, 0, 0, 0, 0, 99, 150, 109, 88, 220, 199, 60, 159, + 40, 11, 4, 0, 40, 11, 4, 0, 5, 0, 28, 0, 116, 46, 116, 120, 116, 85, + 84, 9, 0, 3, 153, 245, 241, 101, 140, 245, 241, 101, 117, 120, 11, 0, + 1, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, + ]); + const line = Buffer.from( + 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n', ); + const body = Buffer.alloc(line.length * 5000); for (let i = 0; i < 5000; i += 1) { - await zipf.writeFile( - 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n', - ); + line.copy(body, i * line.length); } - await zipf.writeFile( - Buffer.from([ - 80, 75, 1, 2, 30, 3, 10, 0, 0, 0, 0, 0, 99, 150, 109, 88, 220, 199, - 60, 159, 40, 11, 4, 0, 40, 11, 4, 0, 5, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 164, 129, 0, 0, 0, 0, 116, 46, 116, 120, 116, 85, 84, 5, 0, 3, 153, - 245, 241, 101, 117, 120, 11, 0, 1, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, 80, - 75, 5, 6, 0, 0, 0, 0, 1, 0, 1, 0, 75, 0, 0, 0, 103, 11, 4, 0, 0, 0, - ]), - ); - await zipf.close(); + const footer = Buffer.from([ + 80, 75, 1, 2, 30, 3, 10, 0, 0, 0, 0, 0, 99, 150, 109, 88, 220, 199, + 60, 159, 40, 11, 4, 0, 40, 11, 4, 0, 5, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 164, 129, 0, 0, 0, 0, 116, 46, 116, 120, 116, 85, 84, 5, 0, 3, 153, + 245, 241, 101, 117, 120, 11, 0, 1, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, 80, + 75, 5, 6, 0, 0, 0, 0, 1, 0, 1, 0, 75, 0, 0, 0, 103, 11, 4, 0, 0, 0, + ]); + await fs.promises.writeFile(zip, Buffer.concat([header, body, footer])); await extractZipArchive(zip, `${tmpdir}/out`); From 752a693b6ddc3d9b855ddb921e3f91d6e3a847b8 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Thu, 4 Jun 2026 21:53:36 +0000 Subject: [PATCH 2/2] fix: prettier formatting for Buffer arrays --- src/utils/__tests__/system.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/utils/__tests__/system.test.ts b/src/utils/__tests__/system.test.ts index 9dfbf9ce..f685a8a6 100644 --- a/src/utils/__tests__/system.test.ts +++ b/src/utils/__tests__/system.test.ts @@ -258,9 +258,9 @@ describe('extractZipArchive', () => { // writes which can exceed the test timeout on slow CI runners. const header = Buffer.from([ 80, 75, 3, 4, 10, 0, 0, 0, 0, 0, 99, 150, 109, 88, 220, 199, 60, 159, - 40, 11, 4, 0, 40, 11, 4, 0, 5, 0, 28, 0, 116, 46, 116, 120, 116, 85, - 84, 9, 0, 3, 153, 245, 241, 101, 140, 245, 241, 101, 117, 120, 11, 0, - 1, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, + 40, 11, 4, 0, 40, 11, 4, 0, 5, 0, 28, 0, 116, 46, 116, 120, 116, 85, 84, + 9, 0, 3, 153, 245, 241, 101, 140, 245, 241, 101, 117, 120, 11, 0, 1, 4, + 0, 0, 0, 0, 4, 0, 0, 0, 0, ]); const line = Buffer.from( 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n', @@ -270,11 +270,11 @@ describe('extractZipArchive', () => { line.copy(body, i * line.length); } const footer = Buffer.from([ - 80, 75, 1, 2, 30, 3, 10, 0, 0, 0, 0, 0, 99, 150, 109, 88, 220, 199, - 60, 159, 40, 11, 4, 0, 40, 11, 4, 0, 5, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 164, 129, 0, 0, 0, 0, 116, 46, 116, 120, 116, 85, 84, 5, 0, 3, 153, - 245, 241, 101, 117, 120, 11, 0, 1, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, 80, - 75, 5, 6, 0, 0, 0, 0, 1, 0, 1, 0, 75, 0, 0, 0, 103, 11, 4, 0, 0, 0, + 80, 75, 1, 2, 30, 3, 10, 0, 0, 0, 0, 0, 99, 150, 109, 88, 220, 199, 60, + 159, 40, 11, 4, 0, 40, 11, 4, 0, 5, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 164, 129, 0, 0, 0, 0, 116, 46, 116, 120, 116, 85, 84, 5, 0, 3, 153, 245, + 241, 101, 117, 120, 11, 0, 1, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, 80, 75, 5, + 6, 0, 0, 0, 0, 1, 0, 1, 0, 75, 0, 0, 0, 103, 11, 4, 0, 0, 0, ]); await fs.promises.writeFile(zip, Buffer.concat([header, body, footer]));