Code Monkey home page Code Monkey logo

Comments (15)

sperlis avatar sperlis commented on August 10, 2024 10

Also experiencing the same issue. Electron 4.0.0 Node 10.11.0.

from electron-edge-js.

tungi52 avatar tungi52 commented on August 10, 2024 1

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;

from electron-edge-js.

gdavidkov avatar gdavidkov commented on August 10, 2024

I have the same issue.

from electron-edge-js.

agracio avatar agracio commented on August 10, 2024

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

from electron-edge-js.

trodi avatar trodi commented on August 10, 2024

@agracio Has there been any progress on this?

from electron-edge-js.

kirilpopov avatar kirilpopov commented on August 10, 2024

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

electron/node-abi#55

from electron-edge-js.

kirilpopov avatar kirilpopov commented on August 10, 2024

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

from electron-edge-js.

trodi avatar trodi commented on August 10, 2024

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.

from electron-edge-js.

kirilpopov avatar kirilpopov commented on August 10, 2024

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: 

from electron-edge-js.

allisonshaw avatar allisonshaw commented on August 10, 2024

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

from electron-edge-js.

tungi52 avatar tungi52 commented on August 10, 2024

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! [email protected] start: `electron .`
npm ERR! Exit status 3221226505
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

from electron-edge-js.

tungi52 avatar tungi52 commented on August 10, 2024

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.

from electron-edge-js.

kirilpopov avatar kirilpopov commented on August 10, 2024

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

from electron-edge-js.

tungi52 avatar tungi52 commented on August 10, 2024

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

from electron-edge-js.

buettner123 avatar buettner123 commented on August 10, 2024

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

from electron-edge-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.