-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NodeJs API + Webpack 2 Production Builds = Error: Received packet in the wrong sequence #1655
Comments
There is a precious issue still open about this, but I'm not sure what the fix is. If you can PR a fix, I'll be happy to merge it. |
|
I saw the previous issue but it mentioned the additional use of Electron? and i wanted to specifiy it was just webPack and the module straight way |
I am honestly unclear where to begin to fix , so would welcome guidance :) |
I haven't used webpack, and really have no idea why it would be broken when using it... |
@jgrauel what's the reason you need webpack in the first place? |
First I started using it so I can write in ES6 and its nice to have the files packed up on the server. So I found out that the error only occurs IF the webpack.optimize.UglifyJsPlugin is used. So that is progress, you can package/minimize without the Uglify. And that gives us a point of where to look. I am looking up if it has to do with specific settings only |
Let me clarify, I know you can write in ES6 without web pack, but it allowed for the transition to be a bit smoother.... |
I use it to compile the code for client side as well :) |
From what I have learned so far, as long as you set the option of mangle:false, the uglify plugin will not cause the error in the code. This is using webpack 2.2 |
do something like https://github.com/apex/apex/blob/master/_examples/babel-webpack2/webpack.config.babel.js I don't recommend mangling anything as that would change variable names in unexpected places. |
@jgrauel Have you found a way to also use |
I was getting "Error: Received packet in the wrong sequence" too but now I have Webpack 4 bundling mysql correctly using the config below: const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); // comes bundled with Webpack 4
module.exports = {
mode: 'production',
target: 'node',
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
mangle: false
},
})
],
}
}; |
This happens to me using the default minifier of Webpack 4: terser. If you want to disable minimisation: optimization: {
minimize: false
} Hopefully this issue can be fixed soon! My bundle size is doubled :( |
@alexjurkiewicz I found this worked and kept my bundle much smaller than
|
Here is a stack trace for this problem. The paths indicate where the source file was found when packaged.
My pool is initialized like |
Is something weird happening in this stack trace or is this a normal stack trace? It almost looks like somehow we've got a short-circuit happening. Is that what it looks like to you? |
We're also seeing this. We use typescript and webpack to bundle packages for AWS Lambda. Not sure why the stack trace is "weird" for us as well. Note:
Current workaround is to disable minification in
We've tried calling query on both a Connection and a Pool using the following config:
webpack.config.js
webpack.global
|
this PR: #2375 might help with this |
Another workaround that avoids having to turn off minification altogether is to tell the Webpack TerserPlugin to avoid mangling important function names. I got the list of function names from #2375 and put them into the optimization: {
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: true,
terserOptions: {
// Preventing mangling of function names fixes "Received packet in the wrong sequence" bug
// See https://github.com/mysqljs/mysql/issues/1655 and https://github.com/mysqljs/mysql/pull/2375/files
keep_fnames: /Packet|ChangeUser|Handshake|Ping|Query|Quit|Sequence|Statistics/,
},
}),
],
}, I'm not sure if all those functions need to be there but I thought it was safer to include them all. |
Hey - I love this module, thanks. I would love to use it in a nodeJs Api we are building, however I am running into an {odd?} issue where I am unable to move my code into a production environment. Every time I compile with webpack without setting devtool="eval" causes any attempt to make a connection result in an Error: Received packet in the wrong sequence.
My understanding is the devtool option controls if and how Source maps are generated from the compile process. I am not sure why exactly this would effect the execution of code, no errors result from actual compiling. Would love to know if there is some setting I am missing or way to get this working. Thanks
The text was updated successfully, but these errors were encountered: