tedious
tedious copied to clipboard
Process crashes with error "NodeError: write after end"
We are using node-mssql, which uses this library to low level connectivity, to sync data from a source to sql server hosted in azure.
Under load, it throws below error and processes crashes.
events.js:292
throw er; // Unhandled 'error' event
^
NodeError: write after end
at writeAfterEnd (/usr/src/app/dist/node_modules/readable-stream/lib/_stream_writable.js:261:12)
at Message.Writable.write (/usr/src/app/dist/node_modules/readable-stream/lib/_stream_writable.js:305:21)
at Readable.ondata (/usr/src/app/dist/node_modules/readable-stream/lib/_stream_readable.js:681:20)
at Readable.emit (events.js:315:20)
at Readable.EventEmitter.emit (domain.js:467:12)
at Readable.read (/usr/src/app/dist/node_modules/readable-stream/lib/_stream_readable.js:483:26)
at flow (/usr/src/app/dist/node_modules/readable-stream/lib/_stream_readable.js:939:34)
at Message.pipeOnDrainFunctionResult (/usr/src/app/dist/node_modules/readable-stream/lib/_stream_readable.js:749:7)
at Message.emit (events.js:315:20)
at Message.EventEmitter.emit (domain.js:467:12)
Emitted 'error' event on Message instance at:
at errorOrDestroy (/usr/src/app/dist/node_modules/readable-stream/lib/internal/streams/destroy.js:98:101)
at Message.onerror (/usr/src/app/dist/node_modules/readable-stream/lib/_stream_readable.js:704:47)
at Message.emit (events.js:315:20)
at Message.EventEmitter.emit (domain.js:467:12)
at errorOrDestroy (/usr/src/app/dist/node_modules/readable-stream/lib/internal/streams/destroy.js:98:101)
at writeAfterEnd (/usr/src/app/dist/node_modules/readable-stream/lib/_stream_writable.js:263:3)
at Message.Writable.write (/usr/src/app/dist/node_modules/readable-stream/lib/_stream_writable.js:305:21)
[... lines matching original stack trace ...]
at Readable.EventEmitter.emit (domain.js:467:12)
Configuration:
{
server: req.dbHost,
user: req.dbUsername,
password: req.dbPassword,
port: req.dbPort || this.getDefaultPort(),
database: req.dbName,
pool: {
max: req.poolSizeMax || 10,
},
trustServerCertificate: true,
encrypt: true,
connectionTimeout: 5 * 60 * 1000, // 5 mins
}
Software versions NodeJS: v14.15.5 node-mssql: 7.0.0 tedious: 11.0.7 SQL Server: Microsoft SQL Azure (RTM) - 12.0.2000.8
I had created this issue with node-mssql (https://github.com/tediousjs/node-mssql/issues/1206) and they suggested to create here.
Note that we have registered unhandledRejection event but that is not seemed to be called in this case. Any help on how to overcome the process crash is much appreciated.
Hi @brsanthu, are you able to reproduce the error using tedious directly?