"未捕获错误:接收到错误序列的数据包"与devtools关闭 - 电子+ MySQL节点驱动程序+ Webpack

时间:2016-10-16 20:17:51

标签: mysql node.js webpack electron devtools

当我使用Electron + Webpack + node MySQL设置一个新项目时,我的生产版本正在抛出:

Uncaught Error: Received packet in the wrong sequence

只有在我的生产版本中保留config.devtools = 'eval'时,错误才会消失,显然这会导致更大的文件大小和一些我想避免的性能问题。

为什么我的project / 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>

第272行mysql / lib / protocol / Protocol.js中的错误来源:

 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;
  }

0 个答案:

没有答案