danielgindi / node-csv-reader

A CSV stream reader, with many many features, and ability to work with the largest datasets
MIT License
35 stars 11 forks source link

Error event is never emitted #24

Closed CamiloManrique closed 3 years ago

CamiloManrique commented 3 years ago

If there is an error while processing the CSV, the error event is never emitted. Take this for example:

let inputStream = Fs.createReadStream(Path.join(__dirname, 'test-auto-parse.csv'), 'utf8');
let output = [];

inputStream
    .pipe(new CsvReadableStream({
        parseNumbers: true,
        parseBooleans: true,
        trim: true,
        asObject: false,
skipHeader: true,
    }))
    .on('data', row => {
        // Imagine an error is thrown here for any reason
    })
    .on('end', () => {
        resolve(output);
    })
    .on('error', err => {
        reject(err); // This is never executed
    });

Instead the error is uncaught.