You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
[webpack-cli] TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
at stringify (/path/to/my/project/node_modules/json-stringify-safe/stringify.js:5:15)
at prep (/path/to/my/project/node_modules/webpack-plugin-serve/lib/routes.js:15:24)
at WebpackPluginServe.<anonymous> (/path/to/my/project/node_modules/webpack-plugin-serve/lib/routes.js:103:58)
at WebpackPluginServe.emit (node:events:406:35)
at WebpackPluginServe.emit (/path/to/my/project/node_modules/webpack-plugin-serve/lib/index.js:158:13)
at /path/to/my/project/node_modules/webpack-plugin-serve/lib/index.js:210:35
at Hook.eval [as callAsync] (eval at create (/path/to/my/project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:42:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/path/to/my/project/node_modules/tapable/lib/Hook.js:18:14)
at Watching._done (/path/to/my/project/node_modules/webpack/lib/Watching.js:273:28)
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.
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 */constnativeJSONStringify=JSON.stringifyconstbigIntReplacer=(key,input)=>{if(typeofinput!=='bigint'){returninput}return`${input}`}JSON.stringify=(input,replacer,space)=>{letoutput=inputif(Array.isArray(replacer)&&typeofoutput==='object'&&!Array.isArray(output)){output=Object.fromEntries(Object.entries(output).filter(([key])=>replacer.includes(key)),)}returnnativeJSONStringify(output,typeofreplacer==='function'
? functionintermediateReplacer(key,value){returnreplacer.call(this,key,bigIntReplacer(key,value))}
: bigIntReplacer,space,)}
Note that the replacer part has not been heavily tested.
Activity
shellscape commentedon Aug 7, 2021
This is an issue with json-stringify-safe, not this lib.
malj commentedon Aug 7, 2021
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.
shellscape commentedon Aug 7, 2021
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.
cahnory commentedon Sep 21, 2021
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:
Note that the replacer part has not been heavily tested.