通过mysql npm发出查询时,Node.js 会引发以下错误。
_stream_readable.js:664
throw new Error('Cannot switch to old mode now.');
Error: Cannot switch to old mode now.
at emitDataEvents (_stream_readable.js:664:11)
at Socket.Readable.resume (_stream_readable.js:649:3)
引发此错误的示例代码:
query = mysqlCLI.query( 'SELECT * FROM foo WHERE bar = 1' );
results = [];
mysqlCLI.resume();
query
.on( 'error', function ( err ) {
console.log( 'Bad Things: ', err );
})
.on( 'result', function ( row ) {
results.push( row );
})
.on( 'end', function (){
mysqlCLI.pause();
dataHandler( results );
});