-
-
Notifications
You must be signed in to change notification settings - Fork 620
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
RangeError: Invalid string length #1919
Comments
Without reproducible steps hard to fix it |
I'm well aware that this not a good bug report and I'm ready to collect as much traces as needed, but I need something to get going. These are the last two trace locations: /**
* @param {CallbackCache<void>} callback signals when the call finishes
* @returns {void}
*/
endIdle(callback) {
this.hooks.endIdle.callAsync(
makeWebpackErrorCallback(callback, "Cache.hooks.endIdle")
);
} compilerCallback(err, stats, lastHash, options, outputOptions) {
const statsErrors = [];
if (!outputOptions.watch || err) {
// Do not keep cache anymore
this.compiler.purgeInputFileSystem();
}
if (err) {
lastHash = null;
logger.error(err.stack || err);
process.exit(1);
}
if (!outputOptions.watch && stats.hasErrors()) {
process.exitCode = 1;
}
if (outputOptions.json === true) {
process.stdout.write(JSON.stringify(stats.toJson(outputOptions), null, 2) + '\n');
} else if (stats.hash !== lastHash) {
lastHash = stats.hash;
if (stats.compilation && stats.compilation.errors.length !== 0) {
const errors = stats.compilation.errors;
errors.forEach((statErr) => {
const errLoc = statErr.module ? statErr.module.resource : null;
statsErrors.push({ name: statErr.message, loc: errLoc });
});
}
//
// THIS IS THE EXCEPTION LOCATION
//
const JSONStats = JSON.stringify(stats.toJson(outputOptions), null, 2);
if (typeof outputOptions.json === 'string') {
try {
writeFileSync(outputOptions.json, JSONStats);
logger.success(`stats are successfully stored as json to ${outputOptions.json}`);
} catch (err) {
logger.error(err);
}
}
return this.generateOutput(outputOptions, stats, statsErrors);
}
} |
Can you try to use it without PnP? |
I'm trying to… it doesn't seem to fail on the reported error, but fails differently (some errors are related to my migration to new dependencies versions, some by disabling PnP), so bare with me on this.... |
I think it is bug on our side, so I want to get better error reporting to search the problem |
I think so as well, but the project is pretty big, everything takes a long time & I want to first remove our bugs … so yeah, give me some time and I'll get there ;-) |
The compilation is VERY slow now ... but that may be related to the fact, that now I'm running the |
Ok… so it seems the only trailing issues I have now with disabled PnP are
Neither of which seem to really be related to this… so I guess that what's to do now is to wait for your linked PR to land & build again with PnP enabled right? |
Already in tracker
Do you use latest |
|
@kubijo Maybe you can create reproducible test repo? |
I think it is fixed in master, but I want more information about |
And I'll try to whip-up something in the morning... It's just that that the
project is a complex tangle and it's pretty late here...
|
So…
On with the archeology then… |
So I've tried a watch mode to se if there will be a difference and… not sure what is the correct place, so I'll drop it here
not an improvement to say the least (I know that the watch error is aleady being fixed, but I've included it for completness) |
also one nitpick… it seems that the |
Already reported, WIP |
@evilebottnawi … it seems to me that the problem with css must be either in {
loader: 'sass-loader',
options: {
// eslint-disable-next-line global-require
implementation: require('sass'),
// webpackImporter: typeof conf.sassWebpackImporter === 'boolean' ? conf.sassWebpackImporter : true,
sassOptions: {
// eslint-disable-next-line global-require
fiber: require('fibers'),
sourceMap: !isProduction,
},
},
} …or {
loader: 'css-loader',
options: {
url: false, // URL calls are already handled by PostCSS
import: true,
modules: !withModules
? false
: {
localIdentContext: paths.styles,
// - In production, short (yet still unique) CSS identifiers are the goal.
// - In Developmnet we want the classes to be be readable.
localIdentName:
isProduction && !inline ? '[md5:hash:base64:8]' : '[name]_[local]_[md5:hash:base64:3]',
},
sourceMap: !isProduction,
// Required because we have postcss-loader pre-processing
importLoaders: 1,
},
} Would you be able to assist me with this somehow? |
@kubijo sorry, no, without full reproducible test repo I can't help |
I have same problem with webpack 5. [webpack-cli] Uncaught exception: RangeError: Invalid string length
[webpack-cli] RangeError: Invalid string length
at JSON.stringify (<anonymous>:null:null)
at Compiler.compilerCallback (<my repo root>/node_modules/webpack-cli/lib/utils/Compiler.js:91:36) that code is here. // lib/utils/Compiler.js
const JSONStats = JSON.stringify(stats.toJson(outputOptions)); // here
if (typeof outputOptions.json === 'string') {
try {
writeFileSync(outputOptions.json, JSONStats);
logger.success(`stats are successfully stored as json to ${outputOptions.json}`);
} catch (err) {
logger.error(err);
}
} Turning it off will work by edit this directly. I have huge size project (total size of chunks have <100MB on prod). I doubt something wrong on |
Fixed in master, hope release will be today, WIP on other issues |
I've already burnt two days on this and I'm just not able to create a minimal repro, so I'm droping this for now as need to do something usefull for the company… Thanks for the other fix though and I'll possibly revisit this at some point… |
Thanks for the fix @evilebottnawi ! Will be released soon? |
@francescocaveglia yes, today/tomorrow |
I want to close this issue, because original problem was solved, anyway @kubijo Can you provide more information to help your migration? |
Describe the bug
I've started the migration to webpack@5 and from what
I can summise it seems that the compilation is able to
pretty much finish, but than it fails with following error.
By what the linked sources are about I've tried
to set
stats: false
, however nothing changed.What is the current behavior?
To Reproduce
Hard to say really, but I'll gladly collect and provide any further information when given pointers.
Please paste the results of
webpack-cli info
here, and mention other relevant informationThe text was updated successfully, but these errors were encountered: