-
Notifications
You must be signed in to change notification settings - Fork 168
Description
What happens?
When using the @duckdb/duckdb-wasm browser bundle in an Electron renderer process, everything works as expected if nodeIntegrationInWorker is set to false. However, when I set nodeIntegrationInWorker: true in the BrowserWindow options, I encounter the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'from')
at b (sha256.js:87:16)
at h (sha256.js:67:16)
at sha256.js:509:17
at sha256.js:526:1
at duckdb-browser-eh.worker.js:1:634
at s3_helper.ts:2:22
at duckdb-browser-eh.worker.ts:33:16
at f5b87803-5a4a-42c1-b1fe-ab1771d8e224:1:1
This error occurs when calling Buffer.from inside the worker. It appears that enabling nodeIntegrationInWorker changes the worker’s environment so that Buffer is not correctly defined, which causes the browser bundle to fail.
To Reproduce
See https://github.com/MasterOdin/electron-duckdb-wasm. Changing this line:
where if it's true then will see the above error(different from the error described in the repo) , and if it's false then the query runs and I get my result.
Great thanks to MasterOdin for his repo!
Browser/Environment:
Electron 26, 37
Device:
Macbook Pro
DuckDB-Wasm Version:
1.29.0
DuckDB-Wasm Deployment:
JS Delivr
Full Name:
Duke Zhang
Affiliation:
IdeaLeap