Electron-packager: Maximum call stack size exceeded when asar is enabled

Created on 21 Sep 2017  路  34Comments  路  Source: electron/electron-packager

  • [x ] I have read the contribution documentation for this project.
  • [x ] I agree to follow the code of conduct that this project follows, as appropriate.
  • [x ] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Main ISSUE:

It appears that electron-packager (npm --prune) is failing when it is trying to delete temporary files (ie. C:\Users\MyUser\AppData\Local\Temp\electron-packager... etc ).

Secondary ISSUE:

As the instructions for debugging and submitting issues state, I turned on 'DEBUG=electron-packager' environment variable to get pertinent information on the problem. This, however, produced exceeding different results, which you will see below.

Console output when you run electron-packager with the environment variable DEBUG=electron-packager. Please include the stack trace if one exists.

IMPORTANT NOTE: The output was significantly different depending on whether I used the DEBUG setting or not. Both output streams are shown below.

CONSOLE OUTPUT A (with DEBUG)

If I turn on the DEBUG=electron-packager environment variable, I get different results, as follows:

C:\git\my-application>gulp build:electron
[15:32:57] Using gulpfile C:\git\my-application\gulpfile.js
[15:32:57] Starting 'build:electron'...
[15:32:57] Launching task to build & package binaries for MyApplication v0.1.10
  electron-packager Electron Packager 9.1.0 +0ms
  electron-packager Node v8.5.0 +1ms
  electron-packager Host Operating system: win32 (x64) +0ms
  electron-packager Packager Options: {"name":"MyApplication","platform":"win32","arch":"x64","dir":"./","out":"./edist/","ignore":[{},{},{},{},{},{},{},{},{}],"icon":"./ClientSide/app/images/icons/translator.ico","asar":{"unpackDir":"node_modules/
{libxml-xsd,libxmljs-mt,nslog}/**/*"},"overwrite":true,"prune":true,"electronVersion":"1.7.7","appCopyright":"Copyright (C) My Company Technologies, Inc. All Rights Reserved","appVersion":"0.1.10","win32metadata":{"CompanyName":["My Application Team"],"ProductName":"MyApplication","FileDescription":"My Application Project Translator","OriginalFilename":"MyApplication.exe"}} +0ms
  electron-packager Target Platforms: win32 +1ms
  electron-packager Target Architectures: x64 +0ms
  electron-packager Application name: MyApplication +0ms
  electron-packager Target Electron version: 1.7.7 +1ms
  electron-packager Ignored path regular expressions: [ /\/\.idea$/,
  /\/\b(ci|ClientSide|WiXInstaller|loaders|edist|ExternalStyles)$/,
  /\/\b(ServerSide\/test)$/,
  /(\.htmlhintrc|\.jscsrrc|\.jshintrc|.stylelintrc|tslint\.json)$/,
  /(gulp\.config\.js|gulpfile\.js)$/,
  /(karma\.conf\.js|karmaBase\.conf\.js|karmaDebug\.conf\.js)$/,
  /(webpack\.config\.js|webpack\.testConfig\.js|webpack\.UnittestConfig\.js|webpackBase\.config\.js)$/,
  /(tsconfig\.json)$/,
  /(\.gitignore|README\.md)$/,
  '/node_modules/electron($|/)',
  '/node_modules/electron-prebuilt(-compile)?($|/)',
  '/node_modules/electron-packager($|/)',
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)',
  '\\.o(bj)?$' ] +0ms
  electron-packager Downloading Electron with options {"platform":"win32","arch":"x64","version":"1.7.7"} +0ms
Packaging app for platform win32 x64 using electron v1.7.7
  electron-packager Creating C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64-template +2s
  electron-packager Extracting C:\Users\MyUser\.electron\electron-v1.7.7-win32-x64.zip to C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64-template +2ms
  electron-packager Initializing app in C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64\MyApplication-win32-x64 from C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64-template template +2s
  electron-packager Ignored paths based on the out param: [ 'C:\\git\\my-application\\edist' ] +3s
  electron-packager Pruning modules via: npm prune --production +0ms
  electron-packager Running asar with the options {"unpackDir":"node_modules/{libxml-xsd,libxmljs-mt,nslog}/**/*"} +1m
C:\git\my-application\node_modules\asar\lib\disk.js:33
      return callback(error)
             ^

RangeError: Maximum call stack size exceeded
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:33:14)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)

C:\git\my-application>

CONSOLE OUTPUT A (without DEBUG)

If I remove DEBUG=electron-packager environment variable, I get the results as follows:

C:\git\my-application>gulp build:electron
[14:13:49] Using gulpfile C:\git\my-application\gulpfile.js
[14:13:49] Starting 'build:electron'...
[14:13:49] Launching task to build & package binaries for MyApplication v0.1.10
Packaging app for platform win32 x64 using electron v1.7.7
[14:15:17] 'build:electron' errored after 1.47 min
[14:15:17] Error: Command failed: npm prune --production
npm ERR! May not delete: C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64\MyApplication-win32-x64\resources\app\node_modules\.bin

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\MyUser\AppData\Roaming\npm-cache\_logs\2017-09-20T21_15_17_397Z-debug.log

    at ChildProcess.exithandler (child_process.js:270:12)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:927:16)
    at Socket.stream.socket.on (internal/child_process.js:348:11)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at Pipe._handle.close [as _onclose] (net.js:545:12)

C:\git\my-application>

extracting the pertinent lines from the recommended log file shows the following :

5857 verbose unlock done using C:\Users\MyUser\AppData\Roaming\npm-cache\_locks\staging-0d81affe015dbade.lock for C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64\MyApplication-win32-x64\resources\app\node_modules\.staging
5858 verbose stack Error: May not delete: C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64\MyApplication-win32-x64\resources\app\node_modules\.bin
5858 verbose stack     at gentlyRm (C:\Program Files\nodejs\node_modules\npm\lib\utils\gently-rm.js:49:15)
5858 verbose stack     at gentlyRmBinRoot (C:\Program Files\nodejs\node_modules\npm\lib\unbuild.js:86:12)
5858 verbose stack     at cb (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\async-map.js:47:24)
5858 verbose stack     at LOOP (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:7:26)
5858 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:18:7
5858 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\utils\gently-rm.js:70:40
5858 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:16:22
5858 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\iferr\index.js:11:16
5858 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
5858 verbose stack     at FSReqWrap.oncomplete (fs.js:153:21)
5859 verbose cwd C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64\MyApplication-win32-x64\resources\app
5860 verbose Windows_NT 6.1.7601
5861 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "prune" "--production"
5862 verbose node v8.5.0
5863 verbose npm  v5.3.0
5864 error May not delete: C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64\MyApplication-win32-x64\resources\app\node_modules\.bin
5865 verbose exit [ 1, true ]

What command line arguments are you passing? Alternatively, if you are using the API, what
parameters are you passing to the packager() function?

I am using the latest electron-packager (9.1.0)
machine is using node 8.5.0 ( using its default included npm 5.3.0)
I am trying to build an electron package on electron 1.7.7 (the variable referred to in the below as electronVersion)

Here is the electron-packager API call code in my gulpfile.js

var packager = require('electron-packager');

var opts = {
    name: pkg.name,
    platform: 'win32',
    arch: 'ia32',                           // ia32, x64 or all
    dir: config.root,                       // source location of app
    out: config.electronbuild,              // destination location for app os/native binaries
    ignore: config.electronignore,          // don't include these directories in the electron app build
    icon: config.icon,
    asar: {unpackDir: config.electroncompiled},  // compress project/modules into an asar blob
    overwrite: true,
    prune: true,
    electronVersion: electronVersion,    // Tell the packager what version of electron to build with
    appCopyright: pkg.copyright,         // copyright info
    appVersion: usableBuildVersion,      // The version of the application we are building
    win32metadata: {                     // Windows Only config data
        CompanyName: pkg.authors,
        ProductName: pkg.name,
        FileDescription: pkg.description,
        OriginalFilename: pkg.name + '.exe'
    }
};

gulp.task('build:electron', function (cb) {

    $.util.log('Launching task to build & package binaries for',
        $.util.colors.cyan(opts.name),
        $.util.colors.magenta('v' + opts.appVersion)
    );
    opts.arch = process.arch;
    packager(opts, function (err, appPath) {
        if (!err) {
            // happy path
            $.util.log(' <- packagerDone()', err, appPath);
        } else {
            cb(err);
        }
    });
});

Please provide either a failing minimal testcase (with a link to the code) or detailed steps to
reproduce your problem. Using electron-quick-start
is a good starting point.

blocked

All 34 comments

Regarding your prune bug, this is a known bug in NPM 5.3.0. Please upgrade to NPM 5.4.2.

Regarding your asar bug:

In order to debug your problem further, we need a minimal testcase to reproduce your problem. Using the electron-quick-start repository as a base, could you please create a minimal Electron app that illustrates the issue you described, and post a link to it here?

Additional note: not sure if this helps but electron-packager succeeds wonderfully and this error does not happen when running on Node 7.10.1 (running its default 4.2.0 npm) and all other variables remain as stated in the original post.

Related to npm prune, I did try running this against the 5.4.2 and found it failed still.

Again, I got one result with the DEBUG switch on, and a different one with it removed.

Here is the result with the DEBUG=electron-packager set--

C:\git\my-application>gulp build:electron
[16:06:28] Using gulpfile C:\git\my-application\gulpfile.js
[16:06:28] Starting 'build:electron'...
[16:06:28] Launching task to build & package binaries for MyApplication v0.1.10
  electron-packager Electron Packager 9.1.0 +0ms
  electron-packager Node v8.5.0 +0ms
  electron-packager Host Operating system: win32 (x64) +2ms
  electron-packager Packager Options: {"name":"MyApplication","platform":"win32","arch":"x64","dir":"./","out":"./edist/","ignore":[{},{},{},{},{},{},{},{},{}],"icon":"./ClientSide/app/images/icons/translator.ico","asar":{"unpackDir":"node_modules{libxml-xsd,libxmljs-mt,nslog}/**/*"},"overwrite":true,"prune":true,"electronVersion":"1.7.7","appCopyright":"Copyright (C) My Company Technologies, Inc. All Rights Reserved","appVersion":"0.1.10","win32metadata":{"CompanyName":["My Application Team"],"ProductName":"MyApplication","FileDescription":"My Application Project Translator","OriginalFilename":"MyApplication.exe"}} +2ms
  electron-packager Target Platforms: win32 +4ms
  electron-packager Target Architectures: x64 +4ms
  electron-packager Application name: MyApplication +3ms
  electron-packager Target Electron version: 1.7.7 +2ms
  electron-packager Ignored path regular expressions: [ /\/\.idea$/,
  /\/\b(ci|ClientSide|WiXInstaller|loaders|edist|ExternalStyles)$/,
  /\/\b(ServerSide\/test)$/,
  /(\.htmlhintrc|\.jscsrrc|\.jshintrc|.stylelintrc|tslint\.json)$/,
  /(gulp\.config\.js|gulpfile\.js)$/,
  /(karma\.conf\.js|karmaBase\.conf\.js|karmaDebug\.conf\.js)$/,
  /(webpack\.config\.js|webpack\.testConfig\.js|webpack\.UnittestConfig\.js|webpackBase\.config\.js)$/,
  /(tsconfig\.json)$/,
  /(\.gitignore|README\.md)$/,
  '/node_modules/electron($|/)',
  '/node_modules/electron-prebuilt(-compile)?($|/)',
  '/node_modules/electron-packager($|/)',
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)',
  '\\.o(bj)?$' ] +0ms
  electron-packager Downloading Electron with options {"platform":"win32","arch":"x64","version":"1.7.7"} +0ms
Packaging app for platform win32 x64 using electron v1.7.7
  electron-packager Creating C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64-template +2s
  electron-packager Extracting C:\Users\MyUser\.electron\electron-v1.7.7-win32-x64.zip to C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64-template +3ms
  electron-packager Initializing app in C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64\MyApplication-win32-x64 from C:\Users\MyUser\AppData\Local\Temp\electron-packager\win32-x64-template template +2s
  electron-packager Ignored paths based on the out param: [ 'C:\\git\\my-application\\edist' ] +3s
  electron-packager Pruning modules via: npm prune --production +0ms
  electron-packager Running asar with the options {"unpackDir":"node_modules/{libxml-xsd,libxmljs-mt,nslog}/**/*"} +1m
C:\git\my-application\node_modules\asar\lib\disk.js:33
      return callback(error)
             ^

RangeError: Maximum call stack size exceeded
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:33:14)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)

C:\git\my-application>

Here is the result with DEBUG variable deleted--

C:\git\my-application>npm -v
5.4.2

C:\git\my-application>gulp build:electron
[16:15:08] Using gulpfile C:\git\my-application\gulpfile.js
[16:15:08] Starting 'build:electron'...
[16:15:08] Launching task to build & package binaries for MyApplication v0.1.10
Packaging app for platform win32 x64 using electron v1.7.7
C:\git\my-application\node_modules\asar\lib\disk.js:33
      return callback(error)
             ^

RangeError: Maximum call stack size exceeded
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:33:14)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)

C:\git\my-application>


I am concerned that use of the DEBUG variable produces wholly different execution paths (according to the output) than when it is not there. Of course, production environments do not normally run with that variable set.

Since the initial error appears to be npm -prune related, I suppose that is what is at root here (when running without the debug env var).

But in the end, it appears that running with DEBUG=electron-packager actually effects the execution path of electron-packager significantly. Should I file a bug on that?

But in the end, it appears that running with DEBUG=electron-packager actually effects the execution path of electron-packager significantly. Should I file a bug on that?

I wouldn't even know where to start debugging that. There's exactly one conditional where it checks whether debug is enabled, and it has nothing to do with pruning. Pruning is slated to be refactored soon, so I don't think it's worth filing a new bug.

I'd still like a minimal testcase for the asar bug. It might end up that the bug needs to be upstreamed to the asar module.

I'd love to recreate the issue. I haven't used electron-quick-start yet... my project is pretty complex so its a bit of a chicken/egg thing.. I might have to make a project as complex as mine to reproduce the issue, which seems like it may be easier to just post the gulp.config.js (which defines a lot of the electron-packager option variables) contents...

I think it has to do with something in the contents of your project, rather than the config.

@malept I will try to put together an electron-quick-start project today. I found that of the electron projects I work on, the one that has this issue (asar "Maximum call stack size exceeded") has native compiled elements listed in the unpackDir exception property of asar option on the API call. I.E. this line in the options object:

...
    asar: {unpackDir: config.electroncompiled},  // compress project/modules into an asar blob
...

Because our project builds both a client and server side into the app, it's complicated (for me, not an electron guru) to recreate, so it may take a while.

Since the original issue reporter has not responded to the request for additional information in about two weeks, I'm going to assume that they worked around issue. If I'm incorrect, they can respond with a minimal testcase, and I'll reopen.

This issue has now reappeared, as the prune bug has been fixed in npm 5.6.0, but the RangeError: Maximum call stack size exceeded is retained whenever building (with electron-packager) where a native compiled package (in this case libxml-xsd, libxmljs-mt) is listed in the unpackDir exception property of asar option on the API call.

I will try to create a simple example project, but my current project fails with this API call:

var opts = {
    name: pkg.name,
    platform: 'win32',
    arch: 'ia32',                           // ia32, x64 or all
    dir: config.root,                       // source location of app
    out: config.electronbuild,              // destination location for app os/native binaries
    ignore: config.electronignore,          // don't include these directories in the electron app build
    icon: config.icon,
    asar: {unpackDir: config.electroncompiled},  // compress project/modules into an asar blob
    overwrite: true,
    prune: true,
    electronVersion: electronVersion,    // Tell the packager what version of electron to build with
    appCopyright: pkg.copyright,         // copyright info
    appVersion: usableBuildVersion,      // The version of the application we are building
    win32metadata: {                     // Windows Only config data
        CompanyName: pkg.authors,
        ProductName: pkg.name,
        FileDescription: pkg.description,
        OriginalFilename: pkg.name + '.exe'
    }
};

gulp.task('build:electron', function (cb) {

    $.util.log('Launching task to build & package binaries for',
        $.util.colors.cyan(opts.name),
        $.util.colors.magenta('v' + opts.appVersion)
    );
    opts.arch = process.arch;
    packager(opts, function (err, appPath) {
        if (!err) {
            $.util.log(' <- packagerDone()', err, appPath);
            cb();
        } else {
            cb(err);
        }
    });
});

and produces the error previously reported:

RangeError: Maximum call stack size exceeded
    at writeFileListToStream (

I will turn on the DEBUG flag and see if I can get any more details that could be helpful..

@malept If you would rather, I can create a new issue since this one is closed. Or just continue the work here... whatever you prefer.

Just use this issue, please.

As you can see from this debug output, I am building with Node 8.9.4 (latest LTS) using the latest electron 8 (beta) available.

C:\git\my-application>gulp build:electron
[11:39:48] Using gulpfile C:\git\my-application\gulpfile.js
[11:39:48] Starting 'build:electron'...
[11:39:48] Launching task to build & package binaries for MyApplication v0.2.11
  electron-packager Electron Packager 10.1.1 +0ms
  electron-packager Node v8.9.4 +1ms
  electron-packager Host Operating system: win32 (x64) +1ms
  electron-packager Packager Options: {"name":"MyApplication","platform":"win32","arch":"x64","dir":"./","out":"./edist/","ignore":[{},{},{},{},{},{},{},{},{}],"icon":"./ClientSide/app/images/icons/MyApplication.ico","asar":{"unpackDir":"node_modules{libxml-xsd,libxmljs-mt,nslog}/**/*"},"overwrite":true,"prune":true,"electronVersion":"1.8.2-beta.3","appCopyright":"Copyright (C) My Company. All Rights Reserved","appVersion":"0.2.11","win32metadata":{"CompanyName":["My Application Team"],"ProductName":"MyApplication","FileDescription":"My Application Project","OriginalFilename":"MyApplication.exe"}} +0ms
  electron-packager Target Platforms: win32 +2ms
  electron-packager Target Architectures: x64 +2ms
  electron-packager Application name: MyApplication +1ms
  electron-packager Target Electron version: 1.8.2-beta.3 +0ms
  electron-packager Ignored path regular expressions: [ /\/\.idea$/,
  /\/\b(ci|ClientSide|WiXInstaller|loaders|edist|ExternalStyles)$/,
  /\/\b(ServerSide\/test)$/,
  /(\.htmlhintrc|\.jscsrrc|\.jshintrc|.stylelintrc|tslint\.json)$/,
  /(gulp\.config\.js|gulpfile\.js)$/,
  /(karma\.conf\.js|karmaBase\.conf\.js|karmaDebug\.conf\.js)$/,
  /(webpack\.config\.js|webpack\.testConfig\.js|webpack\.UnittestConfig\.js|webpackBase\.config\.js)$/,
  /(tsconfig\.json)$/,
  /(\.gitignore|README\.md)$/,
  '/node_modules/electron($|/)',
  '/node_modules/electron-prebuilt(-compile)?($|/)',
  '/node_modules/electron-packager($|/)',
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)',
  '\\.o(bj)?$' ] +0ms
  electron-packager Downloading Electron with options {"platform":"win32","arch":"x64","version":"1.8.2-beta.3"} +0ms
Packaging app for platform win32 x64 using electron v1.8.2-beta.3
  electron-packager Creating C:\Users\joe_developer\AppData\Local\Temp\electron-packager\win32-x64-template +16s
  electron-packager Extracting C:\Users\joe_developer\.electron\electron-v1.8.2-beta.3-win32-x64.zip to C:\Users\joe_developer\AppData\Local\Temp\electron-packager\win32-x64-template +5ms
  electron-packager Initializing app in C:\Users\joe_developer\AppData\Local\Temp\electron-packager\win32-x64\MyApplication-win32-x64 from C:\Users\joe_developer\AppData\Local\Temp\electron-packager\win32-x64-template template +0ms
  electron-packager Ignored paths based on the out param: [ 'C:\\git\\my-application\\edist' ] +18s
  electron-packager Pruning modules via: npm prune --production +0ms
  electron-packager Running asar with the options {"unpackDir":"node_modules/{libxml-xsd,libxmljs-mt,nslog}/**/*"} +3m
C:\git\my-application\node_modules\asar\lib\disk.js:33
      return callback(error)
             ^

RangeError: Maximum call stack size exceeded
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:33:14)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)
    at writeFileListToStream (C:\git\my-application\node_modules\asar\lib\disk.js:35:12)

C:\git\my-application>

This is with DEBUG=electron-packager

My guess without a minimal testcase would be that there are either way too many nested folders in at least one of the node modules that you're unpacking, or there's some sort of recursive symlink somewhere.

I am building a project based on https://github.com/electron/electron-quick-start now... and will try to reproduce the problem therein and get it back to you...

@malept Good news! I have recreated the problem using the quick start app project on node 8.9.4.

Unfortunately, I can't push the project from my dev environment do to IT restrictions on my PC. How might I get my version of the electron-quick-start project that reproduces the bug up to a repo ? Is there a link / guide that explains how to do this via the web rather than git push?

Perhaps make a diff between the original electron-quick-start and yours, upload the diff as a gist, and then later apply the diff and git push it outside of the IT-restricted PC.

I figured it out... I made a fork of the repo, and updated it and posted it:

https://github.com/corvinrok/electron-quick-start

Works fine for me on Linux _(I edited the gulpfile.js to remove platform and arch so that it uses the host platform/arch)_. I'm actually having more trouble with running electron-rebuild on libxml-xsd. Strange C++ linking errors that look like these: https://github.com/albanm/node-libxml-xsd/issues/24

@malept I had electron-rebuild failures on Windows for a while too with libxml-xsd until I upgraded to the latest C++11 compiler (by updating my version of Visual Studio from 2013 to 2017). Of course, that is a Windows specific solution to the V8 headers compilation needs of the native module (libxml-xsd). I don't do anything on Linux, so I can't speak to the errors you mentioned.

That said, just to be clear- the original error I reported in this thread I have found and verified on Windows only, and I didn't try it elsewhere (Mac or Linux).

I don't have a Windows machine to test on, so the only advice I can give is to either set tmpdir: false (which is a longshot) or just disable ASAR support. I'm inclined to believe that this is more of an issue with the asar module than Electron Packager.

No Windows machine? :(

Unfortunately, I can't remove ASAR support at this point.

Sadly, the tmpdir:false workaround is also a no go. It produces the following results:

C:\git\electron-quick-start>gulp build:electron
[10:38:11] Using gulpfile C:\git\electron-quick-start\gulpfile.js
[10:38:11] Starting 'clean:electron'...
[10:38:11] Cleaning: ./edist/
[10:38:11] delete done
[10:38:11] Finished 'clean:electron' after 12 ms
[10:38:11] Starting 'build:electron'...
[10:38:11] Launching task to build & package binaries for my-electron-app v1.1.1
  electron-packager Electron Packager 10.1.1 +0ms
  electron-packager Node v8.9.4 +1ms
  electron-packager Host Operating system: win32 (x64) +0ms
  electron-packager Packager Options: {"name":"my-electron-app","platform":"win32","arch":"x64","dir":"./","out":"./edist/","ignore":[{},{},{},{},{},{},{},{},{}],"asar":{"unpackDir":"node_modules/{libxml-xsd,libxmljs-mt,nslog}/**/*"},"overwrite":tru
e,"prune":true,"tmpdir":false,"electronVersion":"1.8.2-beta.3","appCopyright":"Copyright (C) Corvin Rok","appVersion":"1.1.1","win32metadata":{"CompanyName":["My Electron Application Team"],"ProductName":"my-electron-app","FileDescription":"A minima
l Electron application","OriginalFilename":"my-electron-app.exe"}} +0ms
  electron-packager Target Platforms: win32 +0ms
  electron-packager Target Architectures: x64 +1ms
  electron-packager Application name: my-electron-app +0ms
  electron-packager Target Electron version: 1.8.2-beta.3 +1ms
  electron-packager Ignored path regular expressions: [ /\/\.idea$/,
  /\/\b(ci|ClientSide|WiXInstaller|loaders|edist|ExternalStyles)$/,
  /\/\b(ServerSide\/test)$/,
  /(\.htmlhintrc|\.jscsrrc|\.jshintrc|.stylelintrc|tslint\.json)$/,
  /(gulp\.config\.js|gulpfile\.js)$/,
  /(karma\.conf\.js|karmaBase\.conf\.js|karmaDebug\.conf\.js)$/,
  /(webpack\.config\.js|webpack\.testConfig\.js|webpack\.UnittestConfig\.js|webpackBase\.config\.js)$/,
  /(tsconfig\.json)$/,
  /(\.gitignore|README\.md)$/,
  '/node_modules/electron($|/)',
  '/node_modules/electron-prebuilt(-compile)?($|/)',
  '/node_modules/electron-packager($|/)',
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)',
  '\\.o(bj)?$' ] +0ms
  electron-packager Downloading Electron with options {"platform":"win32","arch":"x64","version":"1.8.2-beta.3"} +0ms
Packaging app for platform win32 x64 using electron v1.8.2-beta.3
  electron-packager Creating C:\git\electron-quick-start\edist\win32-x64-template +218ms
  electron-packager Extracting C:\Users\{user}\.electron\electron-v1.8.2-beta.3-win32-x64.zip to C:\git\electron-quick-start\edist\win32-x64-template +20ms
  electron-packager Initializing app in edist\my-electron-app-win32-x64 from C:\git\electron-quick-start\edist\win32-x64-template template +0ms
  electron-packager Ignored paths based on the out param: [ 'C:\\git\\electron-quick-start\\edist' ] +2s
[10:38:13] 'build:electron' errored after 1.79 s
[10:38:13] Error: Cannot copy 'C:\git\electron-quick-start' to a subdirectory of itself, 'C:\git\electron-quick-start\edist\my-electron-app-win32-x64\resources\app'.
    at checkDest (C:\git\electron-quick-start\node_modules\electron-packager\node_modules\fs-extra\lib\copy\copy.js:141:19)
    at fs.readlink (C:\git\electron-quick-start\node_modules\electron-packager\node_modules\fs-extra\lib\copy\copy.js:239:41)
    at FSReqWrap.oncomplete (fs.js:135:15)

Do you have friends in asar that can look at my version of the sample/demo and consider this as a bug? It's currently the blocking issue for me and my current project from trying to move off of Node 7 to 8 and beyond...

Hmmm, tmpdir: false may no longer be a viable option, with fs-extra v5.

Perhaps set tmpdir to a custom directory?

The asar repository is here: https://github.com/electron/asar

This was reported to the ASAR project/team as issue 139 . I would like to have issue remain open so that the ASAR maintainers can consider the issue and investigate to determine if whether it is indeed an ASAR issue or an electron-packager issue. Once that is determined, it seems to make sense to close whichever is not the package at issue, and keep the other open for resolution.

I would be surprised if this were specifically an Electron Packager issue.

I have a potential fix for this here: https://github.com/electron/asar/pull/140.

We've used this in our environment, with a temporarily forked electron-packager and asar, and it does seem to do the trick, both with our own app, as well as the electron-quick-start reproduction above.

@malept protocol question for you-- I've asked on the pull request thread (https://github.com/electron/asar/pull/140#issuecomment-360576346) if the contributors (of the ASAR package) are going to consider the fix, but it seems there is no active respondents on the project. The contributor and pull request pages are not extant on the community page for the project so I am uncertain how to support consideration of the fix being accepted. What, if anything, is appropriate for me to do to help this fix be considered and merged? It's blocking Windows electron applications with native compiled packages move beyond Node 7, but I am uncertain how to kindly and effectively support progress towards the resolution. Any ideas?

I've pinged one of the maintainers, but that's not guaranteed to have a response in the time frame you might desire, as they are very busy.

@corvinrok You can try our temporary fork, which uses a forked asar, to see if it fixes the issue for you: https://www.npmjs.com/package/@ryverapp/electron-packager.

@mmorton good reminder! thanks, trying it now.

The PR mentioned above has been released in asar 0.14.1, so I'm closing this bug.

It did work. Thank you.

@malept Doesn't the asar 0.14.1 need to be incorporated (package.json) into electron-packager for this bug to be closed?

@corvinrok

Here is the line from the package.json dependencies in 10.1.2:

https://github.com/electron-userland/electron-packager/blob/a39231997303bc0e253e26d8827710e9662dfb35/package.json#L20

The ^ means that it will install the latest 0.14.x version of asar, and as of this comment, that is 0.14.1. So, run npm update (or whatever the equivalent is on yarn, if you use yarn) and it will update the asar dependency accordingly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kdawg1406 picture kdawg1406  路  4Comments

caishengmao picture caishengmao  路  3Comments

andreabisello picture andreabisello  路  3Comments

rafaelcastrocouto picture rafaelcastrocouto  路  3Comments

Liam-Ryan picture Liam-Ryan  路  4Comments