You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
We have an api that can stream from the db to the end user, be we have issue with node 15 & if the stream is destroyed (the end user closes the connection).
Here is a code used to reproduce the issue:
'use strict';const{pipeline: pipelineCb, Writable}=require('stream');constutil=require('util');constpipeline=util.promisify(pipelineCb);constassert=require('assert');constmysql=require('mysql2/promise');/** * Main * @returns {Promise<void>} */asyncfunctionmain(){constpool=awaitmysql.createPool({host: '127.0.0.1',user: 'root',database: 'db'});constconnection=awaitpool.getConnection();// Create the sql stream, select a table with a few hundreds / thousands of row to ensure we have backpressureconstsqlStream=connection.connection.query('SELECT * FROM myTable').stream();// Create a dummy writable streamconstwritable=newWritable({objectMode: true,write: (chunk,encoding,callback)=>{setTimeout(callback,10);// Backpressure}});// Pipeline the sql stream in the dummy writable stream & close the writable stream after a few mstry{awaitPromise.all([pipeline(sqlStream,writable),(async()=>{// Destroy the stream after a few element// pipeline will destroy destroy all the streamsawaitnewPromise(resolve=>setTimeout(resolve,50));writable.destroy();})()]);}catch(e){assert.strictEqual(e.code,'ERR_STREAM_PREMATURE_CLOSE');}awaitpool.end();}main().catch(e=>{console.error(e);process.exitCode=1;});
The code will throw an ERR_INTERNAL_ASSERTION error
The text was updated successfully, but these errors were encountered:
Hi,
We have an api that can stream from the db to the end user, be we have issue with node 15 & if the stream is destroyed (the end user closes the connection).
Here is a code used to reproduce the issue:
The code will throw an
ERR_INTERNAL_ASSERTION
errorThe text was updated successfully, but these errors were encountered: