thejoshwolfe/yazl

Maximum call stack size exceeded on OSX

lettertwo opened this issue · 4 comments

I'm using gulp-atom-shell, which is in turn using gulp-vinyl-zip, which depends on yazl. I'm running into the following problem (OSX 10.10.2):

RangeError: Maximum call stack size exceeded
    at new Buffer (buffer.js)
    at Function.Buffer.concat (buffer.js:199:16)
    at Entry.getLocalFileHeader (.../node_modules/.../yazl/index.js:302:17)
    at pumpEntries (.../node_modules/.../yazl/index.js:166:33)
    at Entry.doFileDataPump (.../node_modules/.../yazl/index.js:81:7)
    at pumpEntries (.../node_modules/.../yazl/index.js:168:11)
    at Entry.doFileDataPump (.../node_modules/.../yazl/index.js:81:7)
    at pumpEntries (.../node_modules/.../yazl/index.js:168:11)
    at Entry.doFileDataPump (.../node_modules/.../yazl/index.js:81:7)
    at pumpEntries (.../node_modules/.../yazl/index.js:168:11)

As best I can tell, it seems to be due to recursion in pumpEntries() (by calling entry.doFileDataPump(), which in turn (possibly?) calls pumpEntries(), etc).

Maybe it's caused by a very deeply nested file structure, but I'm not sure. I do know that pushing the call to entry.doFileDataPump() to the next frame seems to work, but it feels a little hacky, since i don't actually know why the recursion is occurring.

Thoughts?

Just some further clarification re:

…pushing the call to entry.doFileDataPump() to the next frame seems to work…

I changed line 168 to the following:

process.nextTick(entry.doFileDataPump);

It looks like there's a bug where calling addBuffer several hundred times can cause this problem.

I was able to cause a problem that matched your stacktrace, and i implemented a fix for it in version 2.1.1. If this did not solve your problem, please reopen this issue.

👍 Thanks for the quick fix!