nfroidure/gulp-iconfont

Unable to allocate ArrayBuffer

Closed this issue · 11 comments

mxpv commented

Hi guys. I'm getting error, when trying to run plugin:

[13:12:07] Starting 'iconfont'...
[13:12:09] 'iconfont' errored after 1.14 s
[13:12:09] Error: Unable to allocate ArrayBuffer.
    at Object.<anonymous> (D:\GitHub\src\Web\node_modules\gulp-iconfont\node_modules\gulp-ttf2woff2\node_modules\ttf2woff2\jssrc\ttf2woff2.js:1:23345)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (D:\GitHub\src\Web\node_modules\gulp-iconfont\node_modules\gulp-ttf2woff2\node_modules\ttf2woff2\jssrc\index.js:3:27)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
Process terminated with code 1.

Gulp task looks pretty simple

$ = require('gulp-load-plugins')()
gulp.task('iconfont', function() {
    return gulp.src(['./Assets/icons/*.svg'])
        .pipe($.iconfont({ fontName: 'Icons' }))
        .pipe(gulp.dest('./wwwroot/Fonts'));
});

I'm using node 4.1.0, Windows 8
Thanks.

I was getting the same error messages. I went in to the node_modules/gulp-iconfont/package.json file and manually updated the gulp-ttf2* dependencies to the latest version, and that fixed the issue. The plugin author will need to update these in the official file. We could send a pull request, too!

It looks like this repo has the latest gulp-ttf2woff2 version. Maybe it just hasn't been pushed up to the npm registry yet?

mxpv commented

It looks like dependencies are up to date :(

My mistake. I forgot I am using gulp-iconfont 4.0.1 because that's the version that gulp-iconfont-css requires. Sorry I couldn't help!

Since Node4 buffers now rely on the V8 ArrayBuffers it maybe has new limitations. https://nodejs.org/en/blog/release/v4.0.0/

Can you tell me if you use the Emscripten fallback or the C++ wrapper?

mxpv commented

Probably Emscripten fallback, since it's win platform

As a temporary workaround, you can disable the woff2 format if not done yet. i'll try to update to Node 4.1 to reproduce the problem but i'm running a Linux based system so i don't have much chances to get it.

In order to help me to reproduce the bug, you also could give the TTF font that goes out of gulp-svg2ttf from your icon set since it could be related to the content or the size of it.

mxpv commented

Hey. It looks like the problem is caused by Visual Studio's Gulp task runner and there is no problem in module itself. Just verified it from console, everything works fine.

@mxpv not sure I understand, what was the solution?

I now get this also. after weeks or working well, suddenly I get this all the time :/

As far as I know, array buffer allocation problems are typically a lack of memory so it can be either that you do not have enough memory (try shutting down docker :trollface:) or maybe, you hit the maximum memory that the Node process can handle.

Since the problem seems to appear only with VSCode, maybe that they tweaked some compilation variable to make the NodeJS processes tinyer or they may sandbox the subprocesses of VSCode. They may use something like max_old_space_size https://www.fiznool.com/blog/2016/10/01/running-a-node-dot-js-app-in-a-low-memory-environment/ https://gist.github.com/listochkin/10973974 ...

Hope it helps.