-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Random crash #229
Comments
This is an issue with json-stringify-safe, not this lib. |
I know, I submitted a PR, but the lib was last updated in 2015 so I'm not expecting it to be merged anytime soon. I'm not even sure where big ints are coming from because I'm not using them in my code, but the fix seems fairly trivial. I was hoping you'd consider patching it with a custom replacer, if it wouldn't affect anything else. It's a bit tedious having to kill orphaned child processes and restart webpack several times per hour while working with this plugin. |
Yeah the last thing I want to do is handle stringifying myself. Not a fun thing. You might be able to contact the maintainer via Twitter or email. |
While this is not solved, here's a very dirty hack (but at least it'll only affect tooling code) to put in your webpack config file: /**
* This hack is used to prevent an annoying issue
* with a dependency of webpack-plugin-serve:
* - https://github.com/shellscape/webpack-plugin-serve/issues/229
*
* It only runs when bundling and is NOT PRESENT in bundled code
*/
const nativeJSONStringify = JSON.stringify
const bigIntReplacer = (key, input) => {
if (typeof input !== 'bigint') {
return input
}
return `${input}`
}
JSON.stringify = (input, replacer, space) => {
let output = input
if (
Array.isArray(replacer) &&
typeof output === 'object' &&
!Array.isArray(output)
) {
output = Object.fromEntries(
Object.entries(output).filter(([key]) => replacer.includes(key)),
)
}
return nativeJSONStringify(
output,
typeof replacer === 'function'
? function intermediateReplacer(key, value) {
return replacer.call(this, key, bigIntReplacer(key, value))
}
: bigIntReplacer,
space,
)
} Note that the replacer part has not been heavily tested. |
How Do We Reproduce?
Run Webpack CLI in watch mode with the following config:
Expected Behavior
No crashes
Actual Behavior
Webpack process randomly crashes after a while (cca 15 minutes on my machine with Intel i7-8750H and 32 GB RAM) with the following console output:
Related issues:
The text was updated successfully, but these errors were encountered: