epsitec-sa / hazardous

Overload Electron path module for asar.unpacked support
68 stars 6 forks source link

Fatal exception on Electron package for Windows: stack(...).some is not a function #5

Open fretman92 opened 6 years ago

fretman92 commented 6 years ago

Hello @Skywalker13 , thanks for maintening this package.

I'd like to report an error with the dependency callsite used. When installed and launched on some computers, Win10 and Win7 as well, hazardous is not working properly and throwing a fatal exception that crashes my electron app.

Here is the stacktrace it logs:

C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\hazardous\lib\index.js:69
      .some ((site) => {
       ^

TypeError: stack(...).some is not a function
    at hazardous (C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\hazardous\lib\index.js:69:8)
    at Object.hazarPath.normalize (C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\hazardous\lib\index.js:87:10)
    at splitPath (ELECTRON_ASAR.js:58:14)
    at Object.fs.existsSync (ELECTRON_ASAR.js:377:44)
    at Array.<anonymous> (C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\source-map-support\source-map-support.js:81:17)
    at C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\source-map-support\source-map-support.js:53:24
    at retrieveSourceMapURL (C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\source-map-support\source-map-support.js:120:14)
    at Array.<anonymous> (C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\source-map-support\source-map-support.js:137:26)
    at C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\source-map-support\source-map-support.js:53:24
    at mapSourcePosition (C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\source-map-support\source-map-support.js:167:21)
    at wrapCallSite (C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\source-map-support\source-map-support.js:338:20)
    at C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\source-map-support\source-map-support.js:373:26
    at Array.map (native)
    at Function.prepareStackTrace (C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\source-map-support\source-map-support.js:372:24)
    at process.emit (C:\Users\Admin\AppData\Local\Programs\myelectronapp\resources\app.asar\node_modules\source-map-support\source-map-support.js:422:51)
    at process._fatalException (bootstrap_node.js:308:26)

I presume that stack () is returning null or something like that, and I believe it should either be handled, or patched in the original package (I'll try to see with them as well).

Has anybody faced the same problem and uncovered the reason why callsite does not return an array?

Skywalker13 commented 6 years ago

Thanks for the report; I look for this problem the next week.

ghost commented 6 years ago

Got same error on Linux with Electron 3.0.3, make app freezing.

CeQadrat commented 6 years ago

The same problem after upgrading to electron 3.X.X It seems there have been some changes in the stack of calls from the electron and I caught one interesting bug: I had a unpacked module with the joined paths, and paths after join was packed. But at the same time, if you wrap a join in a function (in the example, the map is used), it makes the paths unpacked.

require('hazardous');
const path = require('path');

const config = {
  scripts: ['some/script/path'],
};

const scriptsUrls = config.scripts.map(script => path.join(__dirname, script));
const scriptsUrls2 = [path.join(__dirname, config.scripts[0])];

console.log(scriptsUrls);    // output: ['.../app.asar.unpacked/.../some/script/path']
console.log(scriptsUrls2);    // output: ['.../app.asar/.../some/script/path']

In the second case, electron.asar is present in the stack, because of this, the modules were considered packed It began with electron 2.X.X and the same problem was preserved in electron 3.X.X. But now in electron 3.X.X the stack sometimes even comes null

midevnull commented 5 years ago

I am getting a "Module did not self-register" error on start-up of the packaged app (win10 64bit) with electron 3.1.2. This error does not happen if remove callsite.

Skywalker13 commented 5 years ago

hazardous is broken since electron > 1. I've still not spend time on this.