From a7b46d632a0199203e76cc78e059b3847a9f6cba Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Thu, 2 May 2024 13:06:08 -0500 Subject: [PATCH] fix: race condition? --- src/Node.Stream.CSV.Parse.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Node.Stream.CSV.Parse.js b/src/Node.Stream.CSV.Parse.js index 0673ab5..87991a7 100644 --- a/src/Node.Stream.CSV.Parse.js +++ b/src/Node.Stream.CSV.Parse.js @@ -10,9 +10,9 @@ class ParserWithColumns extends Parser { /** @type {(s: import('csv-parse').Options) => () => ParserWithColumns} */ export const makeImpl = c => () => { const parser = new ParserWithColumns(c) - while (parser.columns.length === 0) { - parser.columns = parser.read() || []; - } + parser.once('data', chunk => { + parser.columns = chunk; + }) return parser }