Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realm is not a constructor #441

Open
dy opened this issue Sep 26, 2021 · 1 comment
Open

Realm is not a constructor #441

dy opened this issue Sep 26, 2021 · 1 comment

Comments

@dy
Copy link

dy commented Sep 26, 2021

Using latest realms-shim.min.js in code as:

  import Realm from "./lib/realms.js"
  const realm = Realm();

Getting

(index):75 Uncaught TypeError: Class constructor j cannot be invoked without 'new'
    at (index):75

But if calling it as constructor realm = new Realm(), getting:

realms.js:1 Uncaught TypeError: Realm is not a constructor
    at new j (realms.js:1)
    at (index):75

I'm confused. I guess will try partytown for now.

@KonghaYao
Copy link

I had the same problem.But I use const sandbox = Realm.makeRootRealm(); // root realm , and it worked.

import Realm from "https://cdn.jsdelivr.net/npm/[email protected]/dist/realms-shim.esm.min.js";
console.log(Realm);
const sandbox = Realm.makeRootRealm(); // root realm
const unsafeCode = "function main(){return 1000};main();";
let result;
try {
    result = sandbox.evaluate(unsafeCode);
} catch (e) {
    result = `Error: ${e}`;
}
console.log(result);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants