laverdet/node-fibers

Cannot be used in Electron V2.0.0

Closed this issue · 12 comments

Hello,
node-fibers cannot be used in Electron V2.0.0 which released recently.
I've tryed to use electron-rebuild to build a new fibers.node, but Electron got stucked (almostly) after running require('fibers').

FYI: node-fibers can be used normally in Electron V1.8.6 after rebuilding fibers.node.
My OS is win10 x64 14393.1670. WindowsTargetPlatformVersion is 10.0.16299.0.

Thx!

This works fine for me on electron 2.0.0 using OS X or Windows. You ran electron-rebuild?

Thank you! I've tryed to run electron-rebuild to build a new fibers.node, but failed on electron 2.0.0 (only succeed on electron 1.8.6 or below).
Did you run electron-rebuild to make node-fibers work fine? Could you please share your new fibers.node with me, so I can test using another fibers.node? Thanks very much!

Actually the electron-rebuild step isn't even necessary. electron 2.0.0 is using node 8.9.3 under the covers and that is definitely supported by fibers. I just confirmed that fibers works in an electron app using the binary in npm. Can you tell me exactly what is failing for you in more clear terms?

I'm sorry! So let me list what I did and got:

  1. Download node-v8.9.3-win-x64.7z from https://nodejs.org/download/release/v8.9.3/, unpack it, and modify path (environment variable) to make sure node can be run everywhere.

  2. Download electron-quick-start-master.zip from https://github.com/electron/electron-quick-start/archive/master.zip, unpack all the files (package.json and so on) to path D:\electron\electron-quick-start-master.

  3. Modify devDependencies in file package.json under path D:\electron\electron-quick-start-master, to "devDependencies": { "electron": "^2.0.0", "fibers": "^2.0.2" }

  4. Use CMD to install and run:

D:\electron\electron-quick-start-master>node -v
v8.9.3

D:\electron\electron-quick-start-master>npm install

> fibers@2.0.2 install D:\electron\electron-quick-start-master\node_modules\fibers
> node build.js || nodejs build.js

'win32-x64-57' exists; testing
Binary is fine; exiting

> electron@2.0.0 postinstall D:\electron\electron-quick-start-master\node_modules\electron
> node install.js

npm notice created a lockfile as package-lock.json. You should commit this file.
added 154 packages in 66.697s

D:\electron\electron-quick-start-master>.\node_modules\.bin\electron.cmd .
  1. When the electron window shows, press Ctrl+Shift+I to open Developer Tools, and run require('fibers') in the Console. Then I got the error as below.
require('fibers')
D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:16 ## There is an issue with node-fibers ##
D:\electron\electron-quick-start-master\node_modules\fibers\bin\win32-x64-57\fibers.node is missing.

Try running this to fix the issue: D:\electron\electron-quick-start-master\node_modules\electron\dist\electron.exe D:\electron\electron-quick-start-master\node_modules\fibers/build
(anonymous) @ D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:16
(anonymous) @ D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:106
Module._compile @ module.js:642
Module._extensions..js @ module.js:653
Module.load @ module.js:561
tryModuleLoad @ module.js:504
Module._load @ module.js:496
Module.require @ module.js:586
require @ internal/module.js:11
(anonymous) @ VM127:1
D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:21 Error: A dynamic link library (DLL) initialization routine failed.
\\?\D:\electron\electron-quick-start-master\node_modules\fibers\bin\win32-x64-57\fibers.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
    at Object.Module._extensions..node (module.js:671:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:504:12)
    at Function.Module._load (module.js:496:3)
    at Module.require (module.js:586:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:13:39)
    at Object.<anonymous> (D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:106:3)
(anonymous) @ D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:21
(anonymous) @ D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:106
Module._compile @ module.js:642
Module._extensions..js @ module.js:653
Module.load @ module.js:561
tryModuleLoad @ module.js:504
Module._load @ module.js:496
Module.require @ module.js:586
require @ internal/module.js:11
(anonymous) @ VM127:1
D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:22 Uncaught Error: Missing binary. See message above.
    at Object.<anonymous> (D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:22)
    at Object.<anonymous> (D:\electron\electron-quick-start-master\node_modules\fibers\fibers.js:106)
    at Module._compile (module.js:642)
    at Object.Module._extensions..js (module.js:653)
    at Module.load (module.js:561)
    at tryModuleLoad (module.js:504)
    at Function.Module._load (module.js:496)
    at Module.require (module.js:586)
    at require (internal/module.js:11)
    at <anonymous>:1:1

Maybe the key is A dynamic link library (DLL) initialization routine failed..

  1. When running D:\electron\electron-quick-start-master\node_modules\electron\dist\electron.exe D:\electron\electron-quick-start-master\node_modules\fibers/build, I got the error as below.
D:\electron\electron-quick-start-master>D:\electron\electron-quick-start-master\node_modules\electron\dist\electron.exe D:\electron\electron-quick-start-master\node_modules\fibers/build

D:\electron\electron-quick-start-master>
win32-x64-57 exists; testing
Problem with the binary; manual build incoming
[Window Title]
Error

[Main Instruction]
A JavaScript error occurred in the main process

[Content]
Uncaught Exception:
TypeError [ERR_INVALID_OPT_VALUE]: The value "Readable {
  _readableState: 
   ReadableState {
     objectMode: false,
     highWaterMark: 16384,
     buffer: BufferList { head: null, tail: null, length: 0 },
     length: 0,
     pipes: null,
     pipesCount: 0,
     flowing: null,
     ended: true,
     endEmitted: false,
     reading: false,
     sync: true,
     needReadable: false,
     emittedReadable: true,
     readableListening: false,
     resumeScheduled: false,
     destroyed: false,
     defaultEncoding: 'utf8',
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null },
  readable: true,
  domain: null,
  _events: {},
  _eventsCount: 0,
  _maxListeners: undefined }" is invalid for option "stdio"
    at internal/child_process.js:899:13
    at Array.reduce (<anonymous>)
    at _validateStdio (internal/child_process.js:825:17)
    at ChildProcess.spawn (internal/child_process.js:270:11)
    at Object.exports.spawn (child_process.js:514:9)
    at build (D:\electron\electron-quick-start-master\node_modules\fibers\build.js:57:5)
    at D:\electron\electron-quick-start-master\node_modules\fibers\build.js:39:5
    at ChildProcess.exithandler (child_process.js:294:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
  1. I've tryed to run electron-rebuild to build a new fibers.node, but failed on electron 2.0.0 (Electron got stucked after running require('fibers')), only succeeded on electron 1.8.6 or below.

Thank you so much for your attention and your great work!

Oh yeah I actually do get the same DLL error. Well maybe electron-rebuild actually is a required step. Here is the file my machine generated:
https://www.dropbox.com/s/6qseirkfqiulsoj/win32-x64-57-fibers.node?dl=0

I just ran electron-rebuild and it rebuilt just fine. This goes under bin\win32-x64-57\fibers.node

electron_stucked
Thanks for your new fibers.node. But it still failed on electron 2.0.0. Electron got stuck after running require('fibers'), nothing returned, and nothing more can be run. Seems like in a dead loop. So strange.

Would you please provide a debug version fibers.node which can record running log and generate log file for further analysis?

Thanks!

Ah I see what you're saying. I had my test in main.js which does work.. it doesn't work when you require from the window. Yeah, I have no idea what that's all about. I'm sorry I'm going to have to punt on this one.

I just tested the new fibers.node in main.js. Yes, it worked fine.
It doesn't work when requiring from the window on electron 2.0.0, but do work when requiring from the window on electron 1.8.6.

Thanks a million! Best wishes to you!

I don't think Chrome, used by Electron, has what is needed to allow Fibers to run?

@KoenLav Just want to avoid "callback-hell" when necessary. I'm using simplesync which is simple to use and requires Fibers.

@firestarman-james I think "callback hell" is much less of an issue today with async/await available to us than it was in 2011 when I started this project. I do recommend that new projects use async/await over fibers.

@laverdet OK, thx for your advice!