【发布时间】:2017-02-25 18:23:25
【问题描述】:
当我使用 Electron + Webpack + node MySQL 建立一个新项目时,我的生产构建正在抛出:
Uncaught Error: Received packet in the wrong sequence
只有在我的生产版本中保留:config.devtools = 'eval' 时错误才会消失,显然这会导致文件变大和一些我想避免的性能问题。
为什么我的项目/mysql 模块在devtools 设置为'' 时崩溃??我几乎找不到类似的报告,只有我有这个问题吗?
webpack.config.js:
...
if (process.env.NODE_ENV === 'production') {
config.devtool = '' // <-------- mysql will throw Uncaught Error if I omit 'eval'
config.plugins.push(
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
)
}
home.js:
<script>
var mysql = require('mysql')
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'EONIC'
})
connection.connect()
connection.query('SELECT * from products', function (err, rows, fields) {
if (err) throw err <---- here will the error happen
console.log(rows)
})
connection.end()
</script>
mysql/lib/protocol/Protocol.js 第 272 行的错误来源:
if (!sequence[packetName]) {
var err = new Error('Received packet in the wrong sequence.');
err.code = 'PROTOCOL_INCORRECT_PACKET_SEQUENCE';
err.fatal = true;
this._delegateError(err);
return;
}
【问题讨论】:
-
我也有同样的问题,你解决了吗?
标签: mysql node.js webpack electron devtools