#Electron childProcess crashes immediately only after built with electron-forge

1 messages · Page 1 of 1 (latest)

snow fable
#

CHECK NEW MESSAGE FOR UPDATED ERROR

Just like the best coding things--I have no idea what's happening here.

My code has worked in the past with previous releases of my app and now it just doesn't. I really don't know.
Basically, when starting my electron app in VS Code, everything works perfectly but when I build it with electron-forge and run the setup.exe the app starts but the button I have that normally calls a child process just doesn't seem to be working.

I don't know exactly what code I would post so here's my Github: https://github.com/spjoes/WardenMC
The button is in play.html that should call "loadGame()" which should send the "startGame" message using ipcRenderer.send to main.js to run the game by starting the childProcess "run_account.js" in the WardenNew folder

My setup:
Windows 11 (tested on Windows 10 as well)
Updated to Electron v22 (was on 19*)
Updated to Electron-Forge 6.0.4 (was on 6-beta*)

* means that my code was on that version for previous releases and it worked then but on this release it started not working so I tried updating. Hopefully that makes sense

Thanks in advance!

GitHub

Contribute to spjoes/WardenMC development by creating an account on GitHub.

snow fable
#

Since posting, All ive discovered is that right when I fork the childprocess it immediately exists with error code 1 and signal of "null".

I tried doing a childProcess.stdout.on('data') but thats not outputting anything since it immediately exits as I explained above

#

Electron childProcess crashes immediately

snow fable
#

Electron childProcess crashes immediately only after built with electron-forge

snow fable
#

Im going to make a new message with all the new info:

Hi! Basically, everything works perfectly when running my electron app through the terminal in vscode while developing. Right when I pack it into an .exe with electron-forge though, the app no longer works as intended. In my app, when clicking "PLAY", it normally starts a childprocess using childprocess.fork in main.js. Except, after being built the childprocess crashes immediately with code 1 and signal null when clicking the "PLAY" button

My setup:
Windows 11 (tested on Windows 10 as well)
Updated to Electron v22 (was on 19*)
Updated to Electron-Forge 6.0.4 (was on 6-beta*)

* means that my code was on that version for previous releases and it worked then but on this release it started not working so I tried updating. Hopefully that makes sense

stiff rampart
#

Use absolute path to js file for fork

#

If problem with file thats run in fork

#

Or your fork script have errors

snow fable
#

The forked script doesnt have errors. If it did, it wouldnt even run in "dev" mode

snow fable
stiff rampart
#

If it run in dev in doesn't mean it 100% run in prod build

snow fable
stiff rampart
#

run your prod app from cmd

#

childProcess.stdout.on('data') for normal data

#

stderr for errors

snow fable
stiff rampart
#

does blank js file work with fork after build?

#

with console.log output in it

#
Error: ENOENT: no such file or directory, open 'C:\<>\AppData\Roaming/warden/auth/auth.json'
    at Object.openSync (node:fs:594:3)
    at Object.func [as openSync] (node:electron/js2c/asar_bundle:2:1822)
    at Object.readFileSync (node:fs:462:35)
    at t.readFileSync (node:electron/js2c/asar_bundle:2:9165)
    at Object.<anonymous> (C:\Git\TEST\WardenMC\out\warden-win32-x64\resources\app\WardenNew\run_account.js:21:17)
    at Module._compile (node:internal/modules/cjs/loader:1141:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1196:10)
    at Module.load (node:internal/modules/cjs/loader:1011:32)
    at Module._load (node:internal/modules/cjs/loader:846:12)
    at f._load (node:electron/js2c/asar_bundle:2:13328) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'C:\\<>\\AppData\\Roaming/warden/auth/auth.json'
}
Exited { code: 1, signal: null }
#

looks like it work

#

if it exit then it have error in it

snow fable
stiff rampart
#

for many reasons

snow fable
#

How would I even go on about debugging something like this?

stiff rampart
#

add console.log for debug output into console

#

run app from command line

#

add logging system

snow fable
stiff rampart
#

just filename.exe

snow fable
#

same issue, no output in cmd

stiff rampart
#

then problem unsolvable

#

i am not able to help you because i am not able to run it

snow fable
#

Wait. I think I solved it.

#

I may be the const { app } = require('electron'); line

#

idk why, but it wasnt needed anyways

#

im gonna build the app