【问题标题】:Node.js Error "Cannot switch to old mode now." with MySQL NPMNode.js 错误“现在无法切换到旧模式。”使用 MySQL NPM
【发布时间】:2013-04-09 05:21:18
【问题描述】:

Node.js 在通过mysql npm 发出查询时抛出以下错误。

_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 );

  });

【问题讨论】:

    标签: mysql node.js


    【解决方案1】:

    这需要进行相当多的故障排除,但最终的解决方法是删除 mysqlCLI.pause();mysqlCLI.resume();。这个问题的奇怪之处在于,代码在 Windows Server 2003 上执行良好,但一旦我通过 Git 克隆,它在 CentOS 5.9 (RHEL) 下就崩溃了。

    【讨论】:

      猜你喜欢
      • 2013-08-20
      • 1970-01-01
      • 2021-02-19
      • 2014-12-02
      • 2015-06-17
      • 2020-05-06
      • 2016-02-08
      • 1970-01-01
      • 2020-11-08
      相关资源
      最近更新 更多