question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"RangeError: Invalid string length" when building --prod

See original GitHub issue

Versions

   _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.5.3
Node: 8.8.1
OS: linux x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

@angular/cdk: 2.0.0-beta.12
@angular/cli: 1.5.3
@angular/flex-layout: 2.0.0-beta.11-b01c2d7
@angular/language-service: 4.4.6
@angular/material: 2.0.0-beta.12
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.3
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack-bundle-analyzer: 2.9.1
webpack: 3.8.1```

### Repro steps

node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod --stats-json --aot

### Observed behavior

/code/myapp/node_modules/@angular/cli/tasks/build.js:55 fs.writeFileSync(path.resolve(this.project.root, outputPath, ‘stats.json’), JSON.stringify(stats.toJson(), null, 2)); ^

RangeError: Invalid string length at JSON.stringify (<anonymous>) at callback (/code/myapp/node_modules/@angular/cli/tasks/build.js:55:102) at emitRecords.err (/code/myapp/node_modules/webpack/lib/Compiler.js:269:13) at Compiler.emitRecords (/code/myapp/node_modules/webpack/lib/Compiler.js:375:38) at emitAssets.err (/code/myapp/node_modules/webpack/lib/Compiler.js:262:10) at applyPluginsAsyncSeries1.err (/code/myapp/node_modules/webpack/lib/Compiler.js:368:12) at next (/code/myapp/node_modules/tapable/lib/Tapable.js:218:11) at Compiler.compiler.plugin (/code/myapp/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4) at next (/code/myapp/node_modules/tapable/lib/Tapable.js:220:14) at Compiler.compiler.plugin (/code/myapp/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:425:13) at next (/code/myapp/node_modules/tapable/lib/Tapable.js:220:14) at callback (/code/myapp/node_modules/copy-webpack-plugin/dist/index.js:125:17) at Compiler.<anonymous> (/code/myapp/node_modules/copy-webpack-plugin/dist/index.js:151:13) at Compiler.applyPluginsAsyncSeries1 (/code/myapp/node_modules/tapable/lib/Tapable.js:222:13) at Compiler.afterEmit (/code/myapp/node_modules/webpack/lib/Compiler.js:365:9) at require.forEach.err (/code/myapp/node_modules/webpack/lib/Compiler.js:354:15)


### Desired behavior
for the build to complete without error

### Mention any other details that might be useful (optional)
just before this happened, memory usage went to over 4gb. This is the output on the terminal:

Date: 2017-11-21T19:39:38.800Z
Hash: 6ed885f416d309dbf8a2 Time: 254657ms chunk {0} main.916d81fb105bd0fbe053.bundle.js (main) 4.49 MB [initial] [rendered] chunk {1} polyfills.7b75f0119f57d635b955.bundle.js (polyfills) 199 kB [initial] [rendered] chunk {2} styles.a276c0e8aee93fbc154b.bundle.css (styles) 1.54 MB [initial] [rendered] chunk {3} inline.8419e018fd791975b6fb.bundle.js (inline) 1.45 kB [entry] [rendered] /home/jmls/development/rtb-dashboard/node_modules/@angular/cli/tasks/build.js:55 fs.writeFileSync(path.resolve(this.project.root, outputPath, ‘stats.json’), JSON.stringify(stats.toJson(), null, 2));


Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
sconixcommented, Dec 12, 2017

I think the memory fixes were only released with angular-cli 1.6.0. At least for us the stats.json is again working with 1.6.0.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 7, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RangeError: Invalid string length · Issue #376 - GitHub
How Do We Reproduce? just build using webpack. webpack --progress --config webpack.
Read more >
Uncaught RangeError: Invalid string length in JavaScript
The issue is that on each iteration you add the text two times, but you assign the result to text again. iteration 1:...
Read more >
RangeError: invalid array length - JavaScript - MDN Web Docs
The JavaScript exception "Invalid array length" occurs when specifying an array length that is either negative, a floating number or exceeds ...
Read more >
HTML : Uncaught RangeError: Invalid string length ... - YouTube
HTML : Uncaught RangeError : Invalid string length when appending to a string in JavaScript [ Beautify Your Computer ...
Read more >
Maximum data we can fetch using getUnderlyingDataAsync
... method to perform a CSV export but if i set the {maxRows: 200000}, I am getting a error Uncaught range error: Invalid...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found