2013-04-08 56 views
0

當通過mysql npm發出查詢時,Node.js會拋出下面的錯誤。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); 

    }); 

回答

1

這花了相當多的故障,但對於這個最終的修復是刪除這兩個mysqlCLI.pause();mysqlCLI.resume();。關於這個問題的奇怪之處在於,代碼在Windows Server 2003上執行得很好,但是一旦我通過Git進行克隆,它就會在CentOS 5.9(RHEL)下破解。

+1

有關某些背景信息,請參閱http://stackoverflow.com/a/20181116/45375。 – mklement0 2013-11-24 21:19:59