apla / node-clickhouse

Yandex ClickHouse driver for nodejs
MIT License
216 stars 50 forks source link

stream.on('error', ...) is not being fired #13

Closed teckays closed 5 years ago

teckays commented 6 years ago

I am trying to gracefully handle stream errors but neither stream.on('error', ...) nor wrapping the stream in a try catch actually work. Any particular ways to gracefully handle the errors without having the app to crash?

apla commented 6 years ago

Please provide more details.

ghost commented 5 years ago

Facing issue while handling stream errors, when performing stream.write(...) neither stream.on('error', ...) is working nor is try catch, not able to handle errors. Application crashing

const clickhouseStream = await clickhouse.query( INSERT INTO ${datasetName} FORMAT JSONEachRow, async error => { console.log('error', error); res.status(500).send(error); } ); await clickhouseStream.write(JSON.stringify(f)); <= crash here await clickhouseStream.end();

clickhouseStream.on('error', async error => { . <= does not execute this block console.log('error', error); res.status(500).send(error); });

events.js:137 throw er; // Unhandled 'error' event ^

Error: connect ECONNREFUSED 127.0.0.1:8123

How to resolve this issue?

nezed commented 5 years ago

@ranjanr46 Better understanding of possible error contexts in JS should help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch

nezed commented 5 years ago

Closing, because there is no activity.