electron-node-red icon indicating copy to clipboard operation
electron-node-red copied to clipboard

Application stop at "Loading Node-RED" when running from dist.

Open eriklindstein opened this issue 4 years ago • 7 comments

If i run the exe created from yarn && yarn dist i get the application window but nothing more. It stops at "Loading Node-RED" i can activate the menu with ALT but see nothing in the console etc.

If i run the application with "yarn start" it works fine. I looked with netstat and see no open port ( I fixed it at 18880 ) if i run it from dist.

I didn't change anything from the example in the readme.

Here is a similar error that have a fix, but i'm not smart enough to implement all that and make a pull request. https://github.com/sakazuki/node-red-desktop/issues/49

Here are output from console: C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked>"Node-RED Electron.exe"

C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked> Starting ARG [ 'C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\Node-RED Electron.exe' ] Store C:\Users\eriklindstein\AppData\Roaming\electron_node_red FlowFile : C:\Users\eriklindstein.node-red\electronflow.json (node:9316) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'withFileTypes' of null at e.readdir (electron/js2c/asar_bundle.js:5:9862) at go$readdir (C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\graceful-fs\graceful-fs.js:201:14) at Object.readdir (C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\graceful-fs\graceful-fs.js:198:12) at Object.readdir (C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\universalify\index.js:5:57) at C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules@node-red\util\lib\i18n.js:53:16 at new Promise () at C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules@node-red\util\lib\i18n.js:51:16 (Use Node-RED Electron --trace-warnings ... to show where the warning was created) (node:9316) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:9316) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Any ideas?

eriklindstein avatar Aug 30 '21 13:08 eriklindstein

I copied the "patch/i18n.js" from sakazuki into "node_modules/@node-red/util/lib/i18n.js" and then it works.

eriklindstein avatar Sep 06 '21 13:09 eriklindstein

before or after install ? IE did you modify the build so it was included correctly ? or just patch it afterwards ?

dceejay avatar Sep 06 '21 16:09 dceejay

Sorry, i just overwrite the file after yarn and before yarn dist

eriklindstein avatar Sep 06 '21 17:09 eriklindstein

Some extra info is that I still get the same console error message but it runs and i get the dashboard..

FlowFile : electronflow.json (node:15264) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'withFileTypes' of null at e.readdir (electron/js2c/asar_bundle.js:5:9862) at go$readdir (C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\graceful-fs\graceful-fs.js:201:14) at Object.readdir (C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\graceful-fs\graceful-fs.js:198:12) at C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\universalify\index.js:10:14 at new Promise (<anonymous>) at Object.readdir (C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\universalify\index.js:7:14) at getFlowsFromPath (C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\@node-red\registry\lib\library.js:28:15) at Object.addNodeExamplesDir [as addExamplesDir] (C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\@node-red\registry\lib\library.js:60:12) at Object.addModule (C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\@node-red\registry\lib\registry.js:220:17) at C:\Users\eriklindstein\projects\electron-node-red\dist\win-unpacked\resources\app.asar\node_modules\@node-red\registry\lib\loader.js:153:34 (Use --trace-warnings ...to show where the warning was created) (node:15264) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:15264) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

eriklindstein avatar Sep 07 '21 12:09 eriklindstein

Right - so the proper fix for this is to fix that (and other) files in the core of Node-RED (shame @sakazuki didn't think to raise an Issue/PR on the main project) - I've started to do that here - https://github.com/node-red/node-red/pull/3139 - so it will need to be merged and a new core released before we can close this properly.

dceejay avatar Sep 10 '21 07:09 dceejay

@dceejay Thank you for drafting the PR. In my investigation, I suspect that it may be a bug in asar, because when I unzip the asar file that causes the error, it works correctly. However, since I could not find any similar reports, I suspect that the problem may occur in rare cases, such as when Electron replaces the fs module. So I wasn't planning to make a pull request as there are multiple places in Node-RED core that use fs-extra, but I'd be happy if this PR could be fixed.

sakazuki avatar Sep 10 '21 08:09 sakazuki

Indeed - it could/should probably be fixed in asar - I guess it probably to do with the way they access into the packed file. But yes we do want to reduce/remove our reliance on fs-extra as we mainly introduced it ages ago because .promises didn't exist is fs at that time (though there are some extra utilities it still offers so we need to be careful), so we will start to work our way through them with this PR.

dceejay avatar Sep 10 '21 09:09 dceejay