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

"App threw an error during load" with latest electron 4.0.0 and electron-edge-js 10.11.0 #32

Closed
buettner123 opened this issue Dec 21, 2018 · 15 comments

Comments

@buettner123
Copy link

buettner123 commented Dec 21, 2018

Hey there,

upgraded to electron 3.0.13 and electron-edge-js 10.11.0 lately and everything was running fine (app could be build, started and .Net integration was working).

After the stable release of electron 4.0.0 I now tried to upgrade it but my electron app fails on start with the following error:

 App threw an error during load
Error: The specified procedure could not be found.
\\?\C:\Users\...\dist\node_modules\electron-edge-js\lib\native\win32\x64\10.11.0\edge_nativeclr.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:160:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (C:\Users\...\dist\node_modules\electron-edge-js\lib\edge.js:59:10)
    at Object.<anonymous> (C:\Users\...\dist\node_modules\electron-edge-js\lib\edge.js:188:3)
error: Uncaught exception:  Error: The specified procedure could not be found.
\\?\C:\Users\...\dist\node_modules\electron-edge-js\lib\native\win32\x64\10.11.0\edge_nativeclr.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:160:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (C:\Users\...\dist\node_modules\electron-edge-js\lib\edge.js:59:10)
    at Object.<anonymous> (C:\Users\...\dist\node_modules\electron-edge-js\lib\edge.js:188:3)

I already tried a clean install by removing the node_module folders.

Here on github it looks like electron-edge-js should already be ready for electron 4.x.x releases but seems its not or do I miss something in my setup?

best regards
Max

@gdavidkov
Copy link
Contributor

I have the same issue.

@sperlis
Copy link

sperlis commented Dec 26, 2018

Also experiencing the same issue. Electron 4.0.0 Node 10.11.0.

@agracio
Copy link
Owner

agracio commented Dec 26, 2018

The issue appears to be with the way 4.0.0 packages Node.js. Previous versions had node.dll file alongside electron.exe while the new version packages Node.js inside electron.exe. I will investigate alternatives but in the meantime would suggest downgrading to 3.x

@trodi
Copy link
Contributor

trodi commented Jan 9, 2019

@agracio Has there been any progress on this?

@kirilpopov
Copy link

Probably related to wrong ABI in electron 3 which causes prebuild to fail

electron/node-abi#55

@kirilpopov
Copy link

The issue appears to be with the way 4.0.0 packages Node.js. Previous versions had node.dll file alongside electron.exe while the new version packages Node.js inside electron.exe. I will investigate alternatives but in the meantime would suggest downgrading to 3.x

"However, in Electron 4.x and higher, the symbols needed by native modules are exported by electron.exe, and there is no node.dll in Electron 4.x."

https://electronjs.org/docs/tutorial/using-native-node-modules#troubleshooting

@trodi
Copy link
Contributor

trodi commented Jan 29, 2019

Continuing with @kirilpopov linked documentation is the required change:

...on Electron 4.x and higher, 'win_delay_load_hook': 'true' is required to load native modules.

Furthermore, this is listed in 4.0's breaking changes:

When building native modules for windows, the win_delay_load_hook variable in the module's binding.gyp must be true (which is the default). If this hook is not present, then the native module will fail to load on Windows, with an error message like Cannot find module.

Therefore, it appears we need to change this setting.

@kirilpopov
Copy link

Tried rebuilding (using electron-rebuild) after updating win_delay_load_hook to true in bindings.gyp file.

Now electron silently dies after start :( - with this in the windows event viewer

Faulting application name: electron.exe, version: 4.0.2.0, time stamp: 0x5c476a58
Faulting module name: ucrtbase.dll, version: 10.0.17763.1, time stamp: 0x309241e0
Exception code: 0xc0000409
Fault offset: 0x000000000006f08e
Faulting process id: 0x57f0
Faulting application start time: 0x01d4b7e42b2dfb8c
Faulting application path: C:\Work\stash\glue-desktop\node_modules\electron\dist\electron.exe
Faulting module path: C:\WINDOWS\System32\ucrtbase.dll
Report Id: 5d6c0066-0f90-4671-a3a9-03e71cc3ea07
Faulting package full name: 
Faulting package-relative application ID: 

@allisonshaw
Copy link
Contributor

allisonshaw commented Feb 13, 2019

I can confirm the results @kirilpopov found.

It looked like it was possibly an issue with the C++ Redistributable dlls beside the edge_nativeclr.node. The ones present are 2015, but build.bat targets 2017. Dropping 2017 dlls doesn't to help. I also tried dropping in ucrtbase.dll (from the Windows event log), but that didn't work either. The same event details in the Windows Event Viewer log.

Here is the verbose output from building. I've tried to bold the flags referenced here: https://electronjs.org/docs/tutorial/using-native-node-modules#troubleshooting. I can post full output if needed...

Link:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX64\x86\link.exe
/ERRORREPORT:QUEUE /OUT:"C:\Workfolder\ES\electron-quick-start\node_modules\electron-edge-js\build\Release\edge_na
tiveclr.node" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib she
ll32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib DelayImp.lib "C:\Users\ashaw.node-gyp\4.0.4\ia32\node.lib" De
layimp.lib /DELAYLOAD:iojs.exe /DELAYLOAD:node.exe
/MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ma
nifest:embed /DEBUG /PDB:"C:\Workfolder\ES\electron-quick-start\node_modules\electron-edge-js\build\Release\edge_n
ativeclr.pdb" /MAP /MAPINFO:EXPORTS /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /SAFESEH /ignor
e:4199 /LTCG:INCREMENTAL /ignore:4248 /DLL Release\obj\edge_nativeclr\utils.obj
Release\obj\edge_nativeclr\clrfunc.obj
Release\obj\edge_nativeclr\clrfuncinvokecontext.obj
Release\obj\edge_nativeclr\nodejsfunc.obj
Release\obj\edge_nativeclr\nodejsfuncinvokecontext.obj
Release\obj\edge_nativeclr\persistentdisposecontext.obj
Release\obj\edge_nativeclr\clrfuncreflectionwrap.obj
Release\obj\edge_nativeclr\clractioncontext.obj
Release\obj\edge_nativeclr\v8synchronizationcontext.obj
Release\obj\edge_nativeclr\callbackhelper.obj
Release\obj\edge_nativeclr\edge.obj
Release\obj\edge_nativeclr\win_delay_load_hook.obj
Creating library C:\Workfolder\ES\electron-quick-start\node_modules\electron-edge-js\build\Release\edge_nativec
lr.lib and object C:\Workfolder\ES\electron-quick-start\node_modules\electron-edge-js\build\Release\edge_nativeclr
.exp
LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker
performance
edge_nativeclr.vcxproj -> C:\Workfolder\ES\electron-quick-start\node_modules\electron-edge-js\build\Release\edge_
nativeclr.node

@tungi52
Copy link

tungi52 commented Feb 14, 2019

I tried rebuilding the code against Electron 4.0.4 (also modified the binding.gyp file mentioned above)

".\node_modules.bin\electron-rebuild.cmd 4.0.4"

and the generated edge_coreclr.node works fine.

With edge_nativecrl.node it produces the following error (at the require line):

npm ERR! errno 3221226505
npm ERR! electron-quick-start@1.0.0 start: `electron .`
npm ERR! Exit status 3221226505
npm ERR!
npm ERR! Failed at the electron-quick-start@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@tungi52
Copy link

tungi52 commented Feb 16, 2019

Some progress: the problem is with the win_delay_load_hook.cc file. Somewhy on module load the symbols are not loaded. When I remove this file and put all the code in the edge.cpp the sample code runs without any error.

@tungi52
Copy link

tungi52 commented Feb 16, 2019

OK, the solution seems very simple:

  • in the binding.gyp file 'win_delay_load_hook' should be 'true'
  • the problematic win_delay_load_hook.cc file should looks like this (added #pragma unmanaged):
#pragma unmanaged
static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) {
  HMODULE m;
  if (event != dliNotePreLoadLibrary)
    return NULL;

  if (_stricmp(info->szDll, "iojs.exe") != 0 &&
      _stricmp(info->szDll, "node.exe") != 0)
    return NULL;

  m = GetModuleHandle(NULL);
  return (FARPROC) m;
}

#pragma unmanaged
decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = load_exe_hook;

@kirilpopov
Copy link

Works on my side.

A possible change in electron-edge-js would be to keep 'win_delay_load_hook' to false and add new file that registers the hook, exactly the same as win_delay_load_hook.cc but with the extra pragma

@tungi52
Copy link

tungi52 commented Feb 18, 2019

Works on my side.

A possible change in electron-edge-js would be to keep 'win_delay_load_hook' to false and add new file that registers the hook, exactly the same as win_delay_load_hook.cc but with the extra pragma

Yes, but it is also important to add /DELAYLOAD:node.exe and /DELAYLOAD:iojs.exe to the linker parameters at binding.gyp as mentioned here: https://electronjs.org/docs/tutorial/using-native-node-modules#troubleshooting

@buettner123
Copy link
Author

Closing the issue as it works fine with 10.11.1 on my side now.

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

No branches or pull requests

8 participants