Skip to content

Commit b1f07c5

Browse files
nazar-pckripken
authored andcommitted
fetch() can be present in some environments like Electron's renderer process, but is not useful outside browser environment (#5596)
1 parent 2c26aa5 commit b1f07c5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/preamble.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2231,7 +2231,8 @@ function integrateWasmJS() {
22312231

22322232
function getBinaryPromise() {
22332233
// if we don't have the binary yet, and have the Fetch api, use that
2234-
if (!Module['wasmBinary'] && typeof fetch === 'function') {
2234+
// in some environments, like Electron's render process, Fetch api may be present, but have a different context than expected, let's only use it on the Web
2235+
if (!Module['wasmBinary'] && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) && typeof fetch === 'function') {
22352236
return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function(response) {
22362237
if (!response['ok']) {
22372238
throw "failed to load wasm binary file at '" + wasmBinaryFile + "'";

0 commit comments

Comments
 (0)