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

Electron - Packaged : Cannot read property 'stdout' of undefined #23

Closed
BertholetDamien opened this issue Jul 11, 2019 · 10 comments · Fixed by #30
Closed

Electron - Packaged : Cannot read property 'stdout' of undefined #23

BertholetDamien opened this issue Jul 11, 2019 · 10 comments · Fixed by #30
Assignees
Labels

Comments

@BertholetDamien
Copy link

BertholetDamien commented Jul 11, 2019

Hi @ukoloff !

I have an issue with Electron. When I packaged the application and launch it, I have this error :
image

Cannot read property 'stdout' of undefined

I just import it on the main thread with :
import 'win-ca';

I use :
Electron : 4.0.2
Electron-builder : 20.43.0
win-ca : 3.1.0

Can you help me with that ?
If you want any other information, tell me !

@ukoloff
Copy link
Owner

ukoloff commented Jul 11, 2019

Yes, but unfortunately, I have no experience with that ASAR thing.

  1. I believe, bad things happen at win-ca/lib/fallback.js at line 86. Can you patch it manually to something like:
  function run(callback){
    child_process.execFile(bin, args)
       .on('error', function(err){console.log('ERROR', err})
  }

repack, run and see what will appear in console?

  1. I'd recommend to mark win-ca/lib/roots.exe as unpack when packing with ASAR. Not sure what it really means, but looks like it can help.

@BertholetDamien
Copy link
Author

BertholetDamien commented Jul 11, 2019

Thank for the quick answer.

I just look, win-ca is already unpack when I build with electron-builder.

But the path for the executable is not good. At the top of the fallback.js, I used that to make it work :

bin = path.join(__dirname, 'roots').replace('app.asar', 'app.asar.unpacked');

And I think a correct version for the run function can be :

function run(callback){
    child_process.execFileSync(bin, args);
    callback();
  }

I just try it and I can make the application start the two changes.
Can you provide a version with theses fix ?

Thank a lot @ukoloff !

@ukoloff
Copy link
Owner

ukoloff commented Jul 12, 2019

But the path for the executable is not good.

Oh, this explains a lot.

Can you provide a version with theses fix ?

Sure, it will follow. But I want to see everything myself, there are too many complains concerning ASAR, I should understand it.

@ukoloff ukoloff self-assigned this Jul 12, 2019
@ukoloff ukoloff added the bug label Jul 12, 2019
@ukoloff
Copy link
Owner

ukoloff commented Jul 12, 2019

I'm totally stuck with ASAR + Electron.

I confirm that changing path to roots.exe fixes the problem.

But I don't understand, how we get incorrect path. If whole win-ca is unpacked, it should run from app.asar.unpacked (so no patch is neccessary)! If it runs from app.asar, documentation says the path to executable should be patched correctly. But it's obviously not.

Then, okay, roots.exe is not found. execFile should return ChildProcess in error state (and it does so in pure Node.js). Instead we get undefined. API is changed in Electron?

And I have no idea how to debug all this. Developer tools are disabled.

Is it possible to get Developer tools (in application packed with electron-builder)

And I think a correct version for the run function can be :

Helas! This breaks win-ca testing suite. In fact this turns async enumeration off.

So far I need more time to mess in the guts of Electron + ASAR. Be patient. please and help me with Developer Tools if you can.

@ukoloff
Copy link
Owner

ukoloff commented Jul 12, 2019

By the way, do you know how to force win-ca to be packed into ASAR (disable auto-unpacking)?

@ukoloff
Copy link
Owner

ukoloff commented Jul 15, 2019

After some exploration, I think: creators of Electron, ASAR, electron-builder etc. over-Microsofted Microsoft itself! This may work (and it works) but such a nightmare should not exist.

So, my only idea is to patch path to roots.exe manually in the code (as you did). It clearly works in your scenario. But if one pack win-ca into ASAR, it will break.

I believe it is a bug inside of asar's patch of child_process module. The point of ASAR is to handle this situation without fiddling the path, but it clearly fails to do so. May be you could post issue to electron-builder and discuss the situation with someone who understands what the fuck happens.

For a long period I amazed the huge wave of criticism on every mention of Electron at one russian IT-site (habr.com to be certain). Now I understand them. It's really awful.

Sorry, but I cannot afford supporting that.

@ukoloff ukoloff closed this as completed Jul 15, 2019
@BertholetDamien
Copy link
Author

Thank you a lot for your time @ukoloff.

I will check how I can fix my issue with all of that when I will have time.

@Ruffus2000
Copy link

By the way, do you know how to force win-ca to be packed into ASAR (disable auto-unpacking)?

in package.json

"asar": {
"smartUnpack": false
},

@Ruffus2000
Copy link

electron/electron#9459

i think this is the key

@ukoloff
Copy link
Owner

ukoloff commented Oct 28, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants