Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: child_process functions not working in packaged app #33070

Closed
3 tasks done
ttrepka opened this issue Feb 24, 2022 · 6 comments
Closed
3 tasks done

[Bug]: child_process functions not working in packaged app #33070

ttrepka opened this issue Feb 24, 2022 · 6 comments
Labels
blocked/need-info ❌ Cannot proceed without more information bug 🪲

Comments

@ttrepka
Copy link

ttrepka commented Feb 24, 2022

Preflight Checklist

Electron Version

17.0.0

What operating system are you using?

macOS

Operating System Version

macOS Mojave 10.14.6

What arch are you using?

x64

Last Known Working Electron version

16.10.0

Expected Behavior

I can run child_process.exec, execFile and spawn from the main process in a packaged app.

Actual Behavior

child_process.exec, execFile and spawn work when I "Run" the project in Electron Fiddle but not when I package using "Tasks" > "Package fiddle...".

Testcase Gist URL

https://gist.github.com/ttrepka/701306ff2283166644e8f76efec3ad81

Additional Information

No response

@sergiou87
Copy link
Contributor

Not sure if it's the same but definitely sounds similar: when trying to run spawn from the main process in a packaged Fiddle moved to /Applications on macOS Catalina, I'm getting a crash. But then the app works normally. I've used this Fiddle to reproduce the issue: https://gist.github.com/cf33b295daf2b42fd3f50a3bec6aea00

It crashes on all 17.x versions and 18.0.0-alpha, but not on 16.x.

On GitHub Desktop, we're getting reports of these crashes since we upgraded the app to 17.0.1: desktop/desktop#13974

@sergiou87
Copy link
Contributor

sergiou87 commented Feb 24, 2022

Oh, not sure about this, but I think my issue is better described in #32718

@ckerr
Copy link
Member

ckerr commented Mar 3, 2022

I think @sergiou87 is right, this does look like a duplicate of the other issue. @ttrepka I see a fix for the other issue has been merged -- could you try this fix out with a version of Electron as described here and see if the problem is fixed or if it persists?

@ckerr ckerr added the blocked/need-info ❌ Cannot proceed without more information label Mar 3, 2022
@ttrepka
Copy link
Author

ttrepka commented Mar 3, 2022

@ckerr I don't know how to test the fix of #32718, I guess I need to wait for the next release of 17.x.y?
As for the fix in Github Desktop you mentioned, it seems they only moved all calls to spawn to the renderer process, which is not a fix, just a workaround.

@ape-casear
Copy link

same problem

childProcess = cp.fork(path.join(__dirname, './child.js'))

    childProcess.on('error', (error) => {
        log('[CHILD] error:' + JSON.stringify(error))
    })
    childProcess.on('message', (msg) => {
        log('[CHILD] message' + msg)
    })
    childProcess.on('disconnect', () => {
        log('[CHILD] disconnect')
    })
    childProcess.on('close', () => {
        log('[CHILD] close')
    })
    childProcess.on('spawn', () => {
        log('[CHILD] spawn')
    })
    childProcess.on('exit', (code, sign) => {
        log(`[CHILD] exit code:${code}  sign:${sign}`)
    })

    log(`[CHILD] pid:${childProcess.pid}, connected: ${childProcess.connected}`)

expect:
[CHILD] pid:341, connected: true
[CHILD] spawn
[CHILD] message I am child
[CHILD] disconnect
[CHILD] exit code:0 sign:null
[CHILD] close

actually:
[CHILD] pid:650, connected: true
[CHILD] spawn
[CHILD] disconnect
[CHILD] exit code:null sign:SIGSEGV
[CHILD] close

@ttrepka
Copy link
Author

ttrepka commented Mar 21, 2022

I guess this really was a duplicate of #32718, fixed by #33114, released in Electron 17.1.1.
I'm closing this.

@ttrepka ttrepka closed this as completed Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/need-info ❌ Cannot proceed without more information bug 🪲
Projects
None yet
Development

No branches or pull requests

4 participants