Closed cameroncruz closed 4 years ago
I built realm@v10.0.0-beta.6 from source with the following change to NetworkTransport.js lines 43-47:
if (!DefaultNetworkTransport.fetch) {
// Try to get it from the global
if (false) {
DefaultNetworkTransport.fetch = fetch.bind(window);
}
which seems to do the trick. Is there any motivation to continue trying to get global fetch?
Are you running this code from the main or a renderer process? If you are available, it would be great to get a repository with a minimal app reproducing this error.
Okay - I managed to reproduce the error in the renderer process, using the following project structure:
{
"name": "realm-js-electron-test",
"version": "0.1.0",
"private": true,
"main": "index.js",
"scripts": {
"test": "electron index.js"
},
"devDependencies": {
"electron": "^8.1.1"
},
"dependencies": {
"realm": "^10.0.0-beta.7"
}
}
target=8.1.1
runtime=electron
disturl=https://atom.io/download/electron
const { app, BrowserWindow } = require("electron");
const Realm = require("realm");
/*
async function useRealm() {
const app = new Realm.App("realmwebtestapp-ybnna");
const credentials = Realm.Credentials.anonymous();
const user = await app.logIn(credentials);
console.log(user);
}
app.on("ready", () => {
console.log("App is ready - lets use Realm");
useRealm().then(() => {
console.log("All done ...");
}, err => {
console.error(err);
process.exit(1);
});
});
*/
app.on("ready", () => {
const window = new BrowserWindow({ webPreferences: { nodeIntegration: true } });
window.loadFile("index.html");
});
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Testing Realm JS</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body>
<h1>Testing Realm JS</h1>
<script>
const Realm = require("realm");
async function useRealm() {
const app = new Realm.App("realmwebtestapp-ybnna");
const credentials = Realm.Credentials.anonymous();
const user = await app.logIn(credentials);
console.log(user);
}
useRealm().then(() => {
console.log("All done ...");
}, err => {
console.error(err);
process.exit(1);
});
</script>
</body>
</html>
The PR has been merged, you can expect a fix for this in the upcoming v10 beta release.
Hi, I'm running into issues integrating basic authentication using Realm with Electron. I believe this issue is related to https://github.com/Azure/azure-sdk-for-js/issues/5143. I noticed that in realm-js, lib/NetworkTransport.js line 46 is where global fetch is being retrieved. While avoiding global fetch is the solution azure-sdk-for-js decided to pursue, is there a short-term solution I can apply to get unblocked? Thanks.
Goals
I want to enable email/password Login based on https://docs.mongodb.com/realm/tutorial/react-native/ for my Electron app.
Expected Results
Calling app.logIn(creds) on a Realm.App to return a valid user.
Actual Results
I receive the following error: Failed to execute 'fetch' on 'Window': member signal is not of type AbortSignal.
Steps to Reproduce
Following this tutorial https://docs.mongodb.com/realm/tutorial/react-native/ with Electron.
Code Sample
Version of Realm and Tooling