Repository navigation
Electron 9 renderer crashes on sqlite module access when reloading the page #1370
Description
Activity
See if #1368 fixes your issue. You can do
npm install mohd-akram/node-sqlite3#fix-segfaultsto try the version in the PR.@mohd-akram, Wanted to test above mentioned fix, but it has been removed. And 5.0.1 isn't released yet...
Any update on failing reload of renderer?
By the way, in the meantime,
app.allowRendererProcessReuse = false;seems to be a temporary workaround.@pamtbaau You can test with the master branch now
npm install mapbox/node-sqlite3. You might need to remove the other version first.Darn, just removed Visual Studio and Python because of limited diskspace... And no pre-built binaries for sqlite3@5.0.1 and node@14.14.0 yet...
TL;DR:
- Patch 5.0.1 doesn't fix reload issue. Reload causes blank window.
- Compiler generated file
napi-v6-win32-x64\node_sqlite3.nodewhile Electron expectednapi-v3-win32-x64\node_sqlite3.node. Renaming the file made Electron happy, but reload causes blank window.
OK, downloaded a few gigs again for Visual Studio, tools and SDK... Took about 90 minutes to finish :-(
Ran
npm install mapbox/node-sqlite3Compilation seems to have worked well. File
"C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\lib\binding\napi-v6-win32-x64\node_sqlite3.node"has been generated.However, Electron throws an error:
Uncaught Error: Cannot find module 'C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\lib\binding\napi-v3-win32-x64\node_sqlite3.node' Require stack: - C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\lib\sqlite3-binding.js - C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\lib\sqlite3.js - C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\dist\index.html at Module._resolveFilename (internal/modules/cjs/loader.js:961) at Function.i._resolveFilename (electron/js2c/renderer_init.js:39) at Module._load (internal/modules/cjs/loader.js:844) at Function.Module._load (electron/js2c/asar.js:769) at Module.require (internal/modules/cjs/loader.js:1023) at require (internal/modules/cjs/helpers.js:77) at Object.<anonymous> (C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\lib\sqlite3-binding.js:4) at Object.<anonymous> (C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\lib\sqlite3-binding.js:7) at Module._compile (internal/modules/cjs/loader.js:1145) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1166)Note that the file generated is:
napi-v6-win32-x64\node_sqlite3.node
While the file requested by Electron is:napi-v3-win32-x64\node_sqlite3.nodeWhen renaming
napi-v6-win32-x64\node_sqlite3.nodetonapi-v3-win32-x64\node_sqlite3.node, sqlite works fine but reload causes empty window.@pamtbaau Are you also getting a crash like the original post? If so, can you paste the crash log?
Did a fresh
npm install. Contrary to my previous test, reload seems to be working most of the time.- It seems to go ok every time when using Ctrl+R (10/10)
- It sometimes (2/10) breaks when reload gets initiated by a rebuild of the app triggering Electron to reload the js/html. After a subsequent change in the code, a reload will succeed.
When it fails with a blank screen and devtools showing 'DevTools' was disconnected from the page`, the following is printed in the terminal:
node-pre-gyp info This Node instance does not support builds for N-API version 6 FATAL ERROR: Error::Error napi_create_reference 1: 00007FF6FD7345C6 node::Buffer::New+45414 2: 00007FF6FD734789 node::Buffer::New+45865 3: 00007FF6FD7345F9 node::Buffer::New+45465 4: 00007FF6FE598F15 napi_fatal_error+149 5: 00007FFAB052FDF7 6: 00007FFAB052CFE2 7: 00007FFAB0531ECD 8: 00007FFAB0531B91 9: 00007FFAB0542633 10: 00007FF6FE59AC26 napi_ref_threadsafe_function+1254 11: 00007FF6FE5B62FC uv_translate_sys_error+2380 12: 00007FF6FD754163 uv_run+307 13: 00007FF6FD71D0D7 node::EmitAsyncDestroy+85607 14: 00007FF6FD71D4B6 node::EmitAsyncDestroy+86598 15: 00007FF6FD70695D node::FreeEnvironment+13 16: 00007FF6FAAA59D8 v8::OutputStream::WriteHeapStatsChunk+130520 17: 00007FF6FD609A65 IsSandboxedProcess+2179013 18: 00007FF6FEE1219F uv_fs_poll_getpath+8729887 19: 00007FF6FE1208B3 GetHandleVerifier+9953331 20: 00007FF6FE1A5071 GetHandleVerifier+10495985 21: 00007FF6FE10C236 GetHandleVerifier+9869750 22: 00007FF6FE223494 GetHandleVerifier+11013140 23: 00007FF6FE222F05 GetHandleVerifier+11011717 24: 00007FF6FE1AD1CE GetHandleVerifier+10529102 25: 00007FF6FE1AF908 GetHandleVerifier+10539144 26: 00007FF6FD4B85CE IsSandboxedProcess+797486 27: 00007FF6FD5FB4E4 IsSandboxedProcess+2120260 28: 00007FF6FD6140DC IsSandboxedProcess+2221628 29: 00007FF6FD613F32 IsSandboxedProcess+2221202 30: 00007FF6FD5FAA04 IsSandboxedProcess+2117476 31: 00007FF6FE3D0725 GetHandleVerifier+12770981 32: 00007FF6FB429BD1 std::__1::vector<v8::CpuProfileDeoptFrame,std::__1::allocator<v8::CpuProfileDeoptFrame> >::vector<v8::CpuProfileDeoptFrame,std::__1::allocator<v8::CpuProfileDeoptFrame> >+1643473 33: 00007FF6FE3D0CDA GetHandleVerifier+12772442 34: 00007FF6FD04499A uv_cond_signal+1217946 35: 00007FF6FD88AD74 GetHandleVerifier+951540 36: 00007FF6FD889061 GetHandleVerifier+944097 37: 00007FF6FCEEBCBC uv_mutex_unlock+2521420 38: 00007FF6FD79BCE4 uv_gettimeofday+278804 39: 00007FF6FD79B9C8 uv_gettimeofday+278008 40: 00007FF6FD78C23B uv_gettimeofday+214635 41: 00007FF6FD79C2DE uv_gettimeofday+280334 42: 00007FF6FCED5B6C uv_mutex_unlock+2430972 43: 00007FF6FD61B994 IsSandboxedProcess+2252532 44: 00007FF6FC2C82E1 v8_inspector::V8StackTraceId::ToString+5677153 45: 00007FF6FD45BB0B IsSandboxedProcess+417899 46: 00007FF6FB55CDEE v8::CpuProfilingOptions::max_samples+784398 47: 00007FF6FA93149F Ordinal0+5279 48: 00007FF7009CEE12 uv_random+16903298 49: 00007FFAE3917034 BaseThreadInitThunk+20 50: 00007FFAE3ABCEC1 RtlUserThreadStart+33You need to build the package for electron since there aren't prebuilt binaries. See the instructions here. Try running:
npm install --save-dev electron-rebuild # Every time you run "npm install", run this: ./node_modules/.bin/electron-rebuildHm, I'm confused... I have in my package.json
"postinstall": "electron-builder install-app-deps"and VC++ is being called when runningnpm install mapbox/node-sqlite3To quote electron-builder:
To ensure your native dependencies are always matched electron version, simply add script "postinstall": "electron-builder install-app-deps" to your package.json.
Output running
npm install mapbox/node-sqlite3:> sqlite3@5.0.1 install C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3 > node-pre-gyp install --fallback-to-build node-pre-gyp WARN Using request for node-pre-gyp https download node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.1/napi-v6-win32-x64.tar.gz node-pre-gyp WARN Pre-built binaries not found for sqlite3@5.0.1 and node@14.14.0 (node-v83 ABI, unknown) (falling back to source compile with node-gyp) Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. nothing.c win_delay_load_hook.cc nothing.vcxproj -> C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\Release\\nothing .lib unpack_sqlite_dep sqlite3.c win_delay_load_hook.cc sqlite3.vcxproj -> C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\Release\\sqlite3 .lib backup.cc database.cc node_sqlite3.cc statement.cc win_delay_load_hook.cc Creating library C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\Release\node_sq lite3.lib and object C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\Release\node_s qlite3.exp node_sqlite3.vcxproj -> C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\Release\\no de_sqlite3.node Copying C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\Release\/node_sqlite3.node to C:/Users/xxx/Documents/Development/Typescript/Electron/electron-test/node_modules/sqlite3/lib/binding/napi-v6-win32-x64\node_sql ite3.node 1 file(s) copied. nI'll try your suggestion though....
Even more confused...
- Removed
electron-builder - Removed script
"postinstall": "electron-builder install-app-deps" - Installed
electron-rebuild - Run
npm install mapbox/node-sqlite3- Compiler is being called and
binding/napi-v6-win32-x64\node_sqlite3.nodeis being generated
- Compiler is being called and
- Running
npx electron-rebuildthrows errors. See below.
Another try:
- Removed node-modules
- Run
npm install- Compiler is being called
- All is well
- Run
npx electron-rebuild- Same errors being thrown.
Errors during compilation using
npx electron-rebuild\ Building module: sqlite3, Completed: 0Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. nothing.c - Building module: sqlite3, Completed: 0 win_delay_load_hook.cc - Building module: sqlite3, Completed: 0 nothing.vcxproj -> C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\Release\\nothing.lib \ Building module: sqlite3, Completed: 0 unpack_sqlite_dep - Building module: sqlite3, Completed: 0 sqlite3.c | Building module: sqlite3, Completed: 0 win_delay_load_hook.cc | Building module: sqlite3, Completed: 0 sqlite3.vcxproj -> C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\Release\\sqlite3.lib - Building module: sqlite3, Completed: 0 backup.cc | Building module: sqlite3, Completed: 0c:\users\xxx\documents\development\typescript\electron\electron-test\node_modules\node-addon-api\napi-inl.h(752): error C3861: 'napi_create_bigint_int64': identifier not found [C: \Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\node_sqlite3.vcxproj] c:\users\xxx\documents\development\typescript\electron\electron-test\node_modules\node-addon-api\napi-inl.h(759): error C3861: 'napi_create_bigint_uint64': identifier not found [C :\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\node_sqlite3.vcxproj] c:\users\xxx\documents\development\typescript\electron\electron-test\node_modules\node-addon-api\napi-inl.h(766): error C3861: 'napi_create_bigint_words': identifier not found [C: \Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\node_sqlite3.vcxproj] c:\users\xxx\documents\development\typescript\electron\electron-test\node_modules\node-addon-api\napi-inl.h(779): error C3861: 'napi_get_value_bigint_int64': identifier not found [C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\node_sqlite3.vcxproj] c:\users\xxx\documents\development\typescript\electron\electron-test\node_modules\node-addon-api\napi-inl.h(787): error C3861: 'napi_get_value_bigint_uint64': identifier not found [C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\node_sqlite3.vcxproj] c:\users\xxx\documents\development\typescript\electron\electron-test\node_modules\node-addon-api\napi-inl.h(795): error C3861: 'napi_get_value_bigint_words': identifier not found [C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\node_sqlite3.vcxproj] c:\users\xxx\documents\development\typescript\electron\electron-test\node_modules\node-addon-api\napi-inl.h(802): error C3861: 'napi_get_value_bigint_words': identifier not found [C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\build\node_sqlite3.vcxproj] × Rebuild Failed An unhandled error occurred inside electron-rebuild node-gyp failed to rebuild 'C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3'. Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1 Error: node-gyp failed to rebuild 'C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3'. Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1 at ModuleRebuilder.rebuildNodeGypModule (C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\electron-rebuild\lib\src\module-rebuilder.js:193:19) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Rebuilder.rebuildModuleAt (C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\electron-rebuild\lib\src\rebuild.js:183:9) at async Rebuilder.rebuild (C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\electron-rebuild\lib\src\rebuild.js:145:17) at async C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\electron-rebuild\lib\src\cli.js:145:9- Removed
@mohd-akram , Any news on this issue you could share?
I think the issue is that the Node.js version you have installed is newer than the Electron one. What Node.js version are you using? I encountered a similar thing while working on #1367 (see #1367 (comment)) and had to set the Node.js versions of the CI to match Electron. I guess you could confirm this by using something like nvm - you'd need to use a version of Node.js < 12.17.0. I'm not sure what the workaround would be to build locally for newer versions, but it should work once 5.0.1 is released and pre-built binaries are available.
Was using node v14.x and downgraded to v12.16.3.
Steps:
- Removed /node_modules
- Reinstalled all dependencies
- Using "sqlite3": "github:mapbox/node-sqlite3"
- NB. No Visual Studio compiler, nor Python available.
- Starting Electron app goes well
- Reload fails
- Add
app.allowRendererProcessReuse = false;to index.js and reload succeeds.
How did the install complete without a compiler?
You may call me stupid, but I just don't know what is going on under the hood...
This is a section form the output of
npm install:[stuff omitted] > sqlite3@github:mapbox/node-sqlite3#833f5cc1332b9213a17873f42a3d3a18dca5afc1 install C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3 > node-pre-gyp install --fallback-to-build node-pre-gyp WARN Using request for node-pre-gyp https download [sqlite3] Success: "C:\Users\xxx\Documents\Development\Typescript\Electron\electron-test\node_modules\sqlite3\lib\binding\napi-v3-win32-x64\node_sqlite3.node" is installed via remote [stuff omitted] > electron-builder install-app-deps • electron-builder version=22.9.1 • loaded configuration file=package.json ("build" field) • rebuilding native dependencies dependencies=sqlite3@5.0.1 platform=win32 arch=x6414 remaining items
@MatteoMeil, Do you perhaps have a minimal test project I can download?
I cannot get my Angular/Electron/Sqlite app to work, unless when using
app.allowRendererProcessReuse = false.Also, does reloading you app work consistently? My app may work 5-10 times and then fail over and over again. After a rebuild, it might not work at all.
My app crashes when reloading even when using sqlite3@5.0.2 if I don't set
app.allowRendererProcessReuse = false. Electron version is 11.3.0. For sure this is not fixed.Nevermind. The issue has to do with the rollback of n-api 6. Version 5.0.1 works fine.
I'm sorry for the issues, I will look at re-enabling N-API 6 as soon as possible.
Reacted by Pat DeSantisHi,
I had the same bug, I m learning Node JS, electron, I wanted to do an app just to learn,
I read a lot of things, and I think there is two way:- If you use the renderer to connect your databas, you need to open a new window wich you will close and open a new one etc..., there is no crash then... You crash only if you reload your BrowserWindow nearly after the first use....
- If You use the main process to connect to your DB, there is no crash if you have rebuild sqlite3
In both case, you need to use IpcMain / ipcRenderer...
I tried both and I had no crash then...
I hope someone will find the BUG with sqlite and the renderer.
Good luck and good job.
Edit: seems to be a security reason on chrome@kewde thanks for looking into this! Do you by any chance have a sense on if this will ship in the next month? No worries if not, I'm just trying to decide whether or not I should invest in a short-term fix in my app if the package will be updated soon.
Same issue (app crashes on reload):
electron: 14.0.0
sqlite3: 5.0.2
websql: 2.0.3We use sqlite3 in renderer process.
It's working (app reloads) on electron: 13.3.0 with app.allowRendererProcessReuse = false
Reacted by zhanfangElectron 14 removed the app.allowRendererProcessReuse option.
@kewde I see you tagged this issue for the next patch version
5.0.3. Is it possible to know the expected release date for this? It is preventing us from upgrading to Electron 14 and up. Happy to help test if we can. Thanks for looking into this!Reacted by Chad Scott@kewde Same issue here.
electron 15.3.1
sqlite3: 5.0.2Resolved by downgrading to electron 13.3 and setting allowRendererProcessReuse to false.
- added a commit that references this issue
on Dec 20, 2021 Would you be able to try with v5.0.3 please? 🙂
Issue Details
Actual Behavior
Since Electron 9 (tried with 9.1.2 and 9.2) seems like the renderer process (?) crashes when using the reload function. Initial loading of the page works fine, but when reloading, the page stays completely white and the DevTools report that it was disconnected from the page.
This seems to be related to the Electron flag
allowRendererProcessReuseand this change in Electron. Since Electron 9,allowRendererProcessReuseis set to true by default. Switching it manually back to false fixes the described issue.Looking at the crash dump (see below) and according to this comment on the Electron ticket I've created this seems to be related to the native sqlite module.
Here is the output of the crash dump with WinDbg:
Any ideas what could be the issue?