From fdd7390cd963c46fac7223a6be0ca5aa271b435f Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Fri, 7 Feb 2025 00:29:49 -0800 Subject: [PATCH] Add test for saving progress on uncaught error --- test/core.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/core.test.js b/test/core.test.js index 26bfa60..2839397 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -519,6 +519,22 @@ suite('CSVWriter', { concurrency: true }, () => { ['row 3', 'c'] ])); }); + test('flushes progress to disk on uncaught error', { concurrency: true }, async (t) => { + const temp = await createTempFile(); + t.after(async () => await unlink(temp)); + await rejects(async () => { + await ReadableStream.from((function* () { + yield '["header1","header2"]'; + yield '["1","1"]'; + throw new Error(); + })()).pipeTo(new CSVWriter(temp)) + }); + await new CSVReader(temp).pipeTo( + csvStreamEqualWritable([ + ['header1', 'header2'], + ['1', '1'], + ])); + }); }); suite('CSVWriter status', { concurrency: true }, () => { -- 2.47.3