danielgindi / node-csv-reader

A CSV stream reader, with many many features, and ability to work with the largest datasets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error event is never emitted

CamiloManrique opened this issue · comments

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.