Skip to content
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: Maximum call stack size exceeded #649

Closed
mashinista opened this issue Mar 6, 2015 · 39 comments
Closed

RangeError: Maximum call stack size exceeded #649

mashinista opened this issue Mar 6, 2015 · 39 comments
Labels

Comments

@mashinista
Copy link

I am getting rangeerror in events.js when using gulp to build /dist. Any ideas. Thanks

Finished 'jshint' after 1.23 s

events.js:72
throw er; // Unhandled 'error' event
^
RangeError: Maximum call stack size exceeded

@eucalyptus30
Copy link

I've the same problem. On windows and debian.

@andrejsstepanovs
Copy link

The same problem using current master 42350b1.

    gulp
    [00:09:18] Using gulpfile /var/www/web-starter-kit/gulpfile.js
    [00:09:18] Starting 'clean'...
    [00:09:18] Finished 'clean' after 23 ms
    [00:09:18] Starting 'default'...
    [00:09:18] Starting 'styles'...
    [00:09:22] 'styles' all files 93.17 kB
    [00:09:22] Finished 'styles' after 4.16 s
    [00:09:22] Starting 'jshint'...
    [00:09:22] Starting 'html'...
    [00:09:24] Starting 'images'...
    [00:09:25] Starting 'fonts'...
    [00:09:25] Starting 'copy'...
    [00:09:26] Finished 'jshint' after 3.35 s

    events.js:72
        throw er; // Unhandled 'error' event
              ^
    RangeError: Maximum call stack size exceeded

@coolguy1990
Copy link

Happening to me aswell.

Its happening because of the gulp html task.

If i comment out

.pipe($.if('*.html', $.minifyHtml()))

everything seems to work fine. Guess there's no minified html files till theres a fix. :)

@addyosmani
Copy link
Contributor

We've been evolving the build process in the material-sprint branch for our next version. Can someone verify if you experience these issues with html minification there too?

@coolguy1990
Copy link

Will do and post the results here. :)

@eucalyptus30
Copy link

i've tried with material-sprint branch.

First, i've :
nodejs -v --> v0.10.36
npm -v --> 2.7.0
sass -v --> Sass 3.4.13 (Selective Steve)

i've run (as root) :

wget https://github.com/google/web-starter-kit/archive/material-sprint.zip
unzip material-sprint.zip
cd web-starter-kit-material-sprint
npm install --global gulp && npm install
chown -R web:web /home/web
su web
gulp serve

gulp serve works perfectly.
But with :

gulp 

i've

web@gwsk:~/web-starter-kit-material-sprint$ gulp
[16:06:18] Using gulpfile ~/web-starter-kit-material-sprint/gulpfile.js
[16:06:18] Starting 'clean'...
[16:06:18] Finished 'clean' after 69 ms
[16:06:18] Starting 'default'...
[16:06:18] Starting 'styles'...
[16:06:27] 'styles' all files 557.3 kB
[16:06:27] Finished 'styles' after 8.64 s
[16:06:27] Starting 'jshint'...
[16:06:27] Starting 'html'...
[16:06:27] Starting 'scripts'...
[16:06:28] Starting 'images'...
[16:06:29] Starting 'styleguide-images'...
[16:06:29] Starting 'fonts'...
[16:06:29] Starting 'copy'...

events.js:72
        throw er; // Unhandled 'error' event
              ^
RangeError: Maximum call stack size exceeded

Like with the master branch.

@coolguy1990
Copy link

Same issue with the material branch and commenting out the html minification, everything works fine.

@mashinista
Copy link
Author

Modifying minifyHtml .pipe in gulpfile.js to read

// Minify any HTML
.pipe($.if('app/**/*.html', $.minifyHtml()))

or

 .pipe($.if('app/*.html', $.minifyHtml()))

instead of

// Minify any HTML
 .pipe($.if('*.html', $.minifyHtml())) 

solves the issue and builds dist fine, but I am not certain if it is proper way to minify html with this gulp.task

@coolguy1990
Copy link

It does solve the error part but um isn't html minify supposed to squeeze all the text together and remove all comments and stuff like it does for the css and js??

@eucalyptus30
Copy link

It does solve the error. but there are no html minify.

@mashinista
Copy link
Author

On the second try, the issue is not caused by the minify pipe and it works as expected. The styleguide.html file is the problem and if removed from the /app everything builds fine with minified html files in /build (index.htm, basic.html, etc) . I still did not narrow down what causes the issue in styleguide.html, but file definitely causes RangeError issue

@mashinista
Copy link
Author

The mess starts below and it builds well without those sections, but there are issues in multiple places thereafter.

@singuerinc
Copy link

This workaround works for me:

sudo node --stack-size=32000 ./node_modules/gulp/bin/gulp

@DevJMD
Copy link

DevJMD commented Mar 13, 2015

@singuerinc, that's a pretty dangerous workaround and doesn't provide a permanent solution to the problem. There's a much, much better way to minify HTML in Gulp, the right way. Forcing a higher stack size is likely to make node unresponsive, especially when it's applied globally to your Gulp module.

@addyosmani
Copy link
Contributor

The workarounds mentioned in this bug so far are unfortunately not sufficient to enable us to filter down all the *.html files in the stream so we can pass it off to minifyHtml(). I'm very curious why the Styleguide is causing the breakage - it looks like it may be down to HTML comments.

Investigating further.

@gustavomelki
Copy link

I had the same problem.

@addyosmani
Copy link
Contributor

Tracing back, it seems like the stack size overflow issues narrow down to gulpjs/vinyl-fs#14 and nodejs/node-v0.x-archive@6820054. Can you verify that you're using Node 0.12 or above and not an older version?

@jasonhodges
Copy link

@bernardolm
Copy link

+1

@dturner
Copy link

dturner commented Mar 19, 2015

Tried the fix from @artifactsauce but am now getting this error:

node_modules/gulp/node_modules/vinyl-fs/node_modules/vinyl/index.js:153
    if (!this.path) throw new Error('No path specified! Can not get relative.'

@edwardbeckett
Copy link

I'm also getting Maximum call stack size exceeded

uname -a
MINGW32_NT-6.1 W7 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys

events.js:85
throw er; // Unhandled 'error' event
^
RangeError: Maximum call stack size exceeded

Stack ...

(relevant)
at Object.async.reduce (d:\Projects\TSDev\node_modules\gulp-minify-html\node_modules\minimize\node_modules\async\lib\async.js:271:15)

Obviously this is could be a red herring. However, here's the stack ref...

https://github.com/caolan/async/blob/master/lib/async.js#L265-276

    // reduce only has a series version, as doing reduce in parallel won't
    // work in many situations.
    async.reduce = function (arr, memo, iterator, callback) {
        async.eachSeries(arr, function (x, callback) {
            iterator(memo, x, function (err, v) {
                memo = v;
                callback(err);
            });
        }, function (err) {
            callback(err, memo);
        });
    };

@garyterry
Copy link

gulp serve works fine for me... but gulp alone throws..
[11:50:13] Using gulpfile ~/dev.server/wsk-0.5.2/gulpfile.js
[11:50:13] Starting 'clean'...
[11:50:13] Finished 'clean' after 25 ms
[11:50:13] Starting 'default'...
[11:50:13] Starting 'styles'...
[11:50:14] gulp-ruby-sass: directory
[11:50:14] gulp-ruby-sass: overwrite components.css
[11:50:15] gulp-ruby-sass: overwrite main.css
[11:50:18] 'styles' all files 93.39 kB
[11:50:18] Finished 'styles' after 5.31 s
[11:50:18] Starting 'jshint'...
[11:50:18] Starting 'html'...
[11:50:19] Starting 'images'...
[11:50:21] Starting 'fonts'...
[11:50:21] Starting 'copy'...
[11:50:21] Finished 'jshint' after 2.95 s

events.js:85
throw er; // Unhandled 'error' event
^
RangeError: Maximum call stack size exceeded

So I'm having the same issue... first build of wsk-0.5.2 on Linux mint
Just now tested the wsk-0.5.3 build... same error.
Using version 0.12.0 of node.js

@ohyouknowwho
Copy link

@garyterry Mashinista's response about modifying the gulpfile html solves the problem but it won't minify the html. You'll get the dist but not the minification.

@levithomason
Copy link

...I'm very curious why the Styleguide is causing the breakage - it looks like it may be down to HTML comments.

@addyosmani Trimming styleguide.html down to ~800 lines makes it pass. This is irregardless of what I remove, comments, script tag, etc. At the break point, even adding a single <p></p> makes it fail.

To be sure, I tested the task against a single new html file. Here are the results:

  • 730 lines of single empty elements fails, regardless of the element. I tested these:
    • <div></div>
    • <p></p>
    • <super-long-nonexistent-element></super-long-nonexistent-element>
  • 729 lines of single empty elements works (with all the elements above).
  • Adding 1000 paragraphs of lorem ipsum, 1 per line, not in an element, let's it continue to pass.
  • Adding the above to one of the elements let's it continue to pass.
  • Adding contents to any two elements, even a single whitespace character, causes it to fail again.

So, it must have something to do with parsing a certain number of elements.

@levithomason
Copy link

Versions:

› node -v && npm -v && gulp -v
v0.10.32
2.1.5
[22:36:47] CLI version 3.8.9
[22:36:47] Local version 3.8.11

Looking a little more into this.

@addyosmani
Copy link
Contributor

Thanks for investigating @levithomason. I wouldn't have thought our node counts would cause any of the tooling to choke, but given the number of folks running into this it's definitely something we want to nail down.

Just to confirm with anyone that hasn't already: disabling HTML minification atm is allowing you to workaround this issue - is that correct? I'll continue exploring upstream minification issues. Sure others have run into this before (at least, I hope!).

@ohyouknowwho
Copy link

@addyosmani Yes, I had another error that followed it in relation to images not copying over, which was resolved from #579

@processnotproduct
Copy link

I'm having this issue as well, I can't seem to figure out what's causing it or how to get around it. At this point I'm going to have to stop using WSK which is really unfortunate.

@garyterry
Copy link

I've been testing the wsk-0.5.3 build on win7 and this is what I've found so far...
So, after downloading build, unpacking and running... $npm install
it throws...

node-sass@2.0.1 postinstall D:\dev.server\test-wsk-0.5.3\node_modules\gulp-sass\node_modules\node-sass
node scripts/build.js
win32-x64-node-0.12 exists; testing
Binary is fine; exiting
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! shasum check failed for \AppData\Local\Temp\npm-1620-5a62423e\registry.npmjs.org\caniuse-db-\caniuse-db-1.0.30000102.tgz
npm ERR! Expected: 1b389c7d440337380970db453f57abd85d5a7cda
npm ERR! Actual: 5b5228eb25d1bf1bdaff8ad1a7bb20d729e26e83
npm ERR! From: https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000102.tgz
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! http://github.com/npm/npm/issues
npm ERR! Please include the following file with any support request:
npm ERR! D:\dev.server\test-wsk-0.5.3\npm-debug.log

Before doing anything to fix this, (for once) I simply tried running npm install again...
and it installed clean... (???) so I install gulp...
$npm install gulp -g
and it installs clean... so I build the wsk...

D:\dev.server\test-wsk-0.5.3>gulp
[10:18:03] Using gulpfile D:\dev.server\test-wsk-0.5.3\gulpfile.js
[10:18:03] Starting 'clean'...
[10:18:03] Finished 'clean' after 11 ms
[10:18:03] Starting 'default'...
[10:18:03] Starting 'styles'...
[10:18:09] 'styles' all files 92.75 kB
[10:18:09] Finished 'styles' after 6.21 s
[10:18:09] Starting 'jshint'...
[10:18:10] Starting 'html'...
[10:18:14] Starting 'images'...
[10:18:17] Starting 'fonts'...
[10:18:17] Starting 'copy'...
[10:18:17] Finished 'jshint' after 8.46 s
events.js:85
throw er; // Unhandled 'error' event
^
RangeError: Maximum call stack size exceeded
at String.replace (native)
at compact (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\lib\helpers.js:34:16)
at Helpers.text (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\lib\helpers.js:223:15)
at enter (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\lib\minimize.js:120:45)
at reduce (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\lib\minimize.js:106:33)
at D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\node_modules\async\lib\async.js:272:13
at iterate (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\node_modules\async\lib\async.js:149:13)
at Object.async.eachSeries (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\node_modules\async\lib\async.js:165:9)
at Object.async.reduce (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\node_modules\async\lib\async.js:271:15)
at Minimize.traverse (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\lib\minimize.js:99:9)
at enter (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\lib\minimize.js:123:16)
at reduce (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\lib\minimize.js:106:33)
at D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\node_modules\async\lib\async.js:272:13
at iterate (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\node_modules\async\lib\async.js:149:13)
at Object.async.eachSeries (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\node_modules\async\lib\async.js:165:9)
at Object.async.reduce (D:\dev.server\test-wsk-0.5.3\node_modules\gulp-minify-html\node_modules\minimize\node_modules\async\lib\async.js:271:15)

and it fails...
So I completely remove styleguide.html (after reading @levithomason previous comments)

and run $gulp again...

D:\dev.server\test-wsk-0.5.3>gulp
[10:23:04] Using gulpfile D:\dev.server\test-wsk-0.5.3\gulpfile.js
[10:23:04] Starting 'clean'...
[10:23:04] Finished 'clean' after 25 ms
[10:23:04] Starting 'default'...
[10:23:04] Starting 'styles'...
[10:23:08] 'styles' all files 92.75 kB
[10:23:08] Finished 'styles' after 3.43 s
[10:23:08] Starting 'jshint'...
[10:23:08] Starting 'html'...
[10:23:09] Starting 'images'...
[10:23:11] Starting 'fonts'...
[10:23:11] Starting 'copy'...
[10:23:11] Finished 'jshint' after 3.81 s
[10:23:12] 'html' all files 4.54 kB
[10:23:12] Finished 'html' after 3.55 s
[10:23:12] 'copy' all files 46.29 kB
[10:23:12] Finished 'copy' after 369 ms
[10:23:12] 'fonts' all files 1.09 MB
[10:23:12] Finished 'fonts' after 387 ms
[10:23:12] 'images' all files 22.63 kB
[10:23:12] Finished 'images' after 2.76 s
[10:23:12] Finished 'default' after 7.58 s

and gulp builds clean,
So, for a laugh... I decide to put the styleguide.html file back into the /app directory and then try running $gulp again... It builds without error... go figure.

So as a final test I run...
$gulp serve:dist
and gulp runs clean... even with the original styleguide.html replaced!
However, certain files are missing from the build '/images/icons' and '/images/touch' aren't being piped into corresponding dist folders

So I've got a build working... mostly, but it's not copying over images and icons properly... everything else seems fine (ie. minify html works). I'm currently running checks to see if anything else is missing in $gulp serve:dist process. I'll try and replicate this on Linux Mint tonight. Will advise.

@ueqt
Copy link

ueqt commented Mar 26, 2015

This issue should be caused by new version of gulp-minify-html and gulp-cache
We can change package.json

"gulp-minify-html": "0.1.5",
"gulp-cache": "0.2.2",

And delete node_modules, then do npm install again, it will works.

@garyterry
Copy link

Such a simple fix, DOH!
Just completed a new build with wsk-0.5.3 and not using the latest versions of the two packages has fixed it... Everything runs clean, all pipes working... ready to continue. Thanks @ueqt !

@addyosmani
Copy link
Contributor

If it's possible to get verification from 1-2 more folks that the fix suggested by @ueqt addresses this, I'll get a new release out with that patch in there asap.

@patrickjaja
Copy link

Thx for that solution, now its building successful (serve and serve:dist) (Win7 - 64 bit).

$ node -v & npm -v
v0.12.0 2.5.1

@levithomason
Copy link

Using exact versions works for me:

"gulp-minify-html": "0.1.5",
"gulp-cache": "0.2.2",

@bernardolm
Copy link

Thanks @ueqt, this works for me. Everthing's ok now.

@edwardbeckett
Copy link

Confirming @ueqt solution works for the latest build running Msys / Win 7 64

MINGW32_NT-6.1 W7 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys

    "gulp-cache": "0.2.2",
    "gulp-minify-html": "0.1.5",

Thanks @ueqt

@ohyouknowwho
Copy link

@ueqt this solved the issues with the 0.5.2 build too.

@addyosmani
Copy link
Contributor

The latest tagged version includes this fix: https://github.com/google/web-starter-kit/releases

@mashinista
Copy link
Author

fixed with 0.5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests