Skip to content

Framing fails in IE11 and Edge with "Invalid calling object" #319

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

Closed
AlexeyMz opened this issue Jul 8, 2019 · 6 comments
Closed

Framing fails in IE11 and Edge with "Invalid calling object" #319

AlexeyMz opened this issue Jul 8, 2019 · 6 comments

Comments

@AlexeyMz
Copy link

AlexeyMz commented Jul 8, 2019

In IE11 framing fails at setImmediate() call, probably due to an Internet Explorer-specific bug which requires setImmediate() to be called only on window context.

There is already a check related to this issue for IE10 but it doesn't work on IE11 because it defines setImmediate function:
https://github.com/digitalbazaar/jsonld.js/blob/master/lib/util.js#L37

EDIT: It also fails in Edge for the same reason.

@aljones15
Copy link
Contributor

aljones15 commented Jul 8, 2019

thanks for this one. if the issue just consists of adding window to setImmediate you could probably just submit a PR for it.

@AlexeyMz AlexeyMz changed the title Framing fails in IE11 with "Invalid calling object" Framing fails in IE11 and Edge with "Invalid calling object" Jul 9, 2019
@AlexeyMz
Copy link
Author

AlexeyMz commented Jul 9, 2019

Hi @aljones15, thanks for a quick reply.

I tried to replace _setImmediate-related lines here:
https://github.com/digitalbazaar/jsonld.js/blob/master/lib/util.js#L33
with this:

let _setImmediate = typeof setImmediate === 'function' && setImmediate;
try {
  _setImmediate(() => {/* nothing */});
} catch (e) {
  // prevent "Invalid calling object" error in IE and Edge
  _setImmediate = fn => setImmediate(fn);
}

And this change fixes the issue in Edge. Unfortunately it still fails in IE, now with this error:

Unhandled promise rejection
SyntaxError: Expected ')'
   at ./node_modules/rdf-canonize/lib/index.js (eval code:2135:1)
   at __webpack_require__ (eval code:25:12)
   at Anonymous function (eval code:46:1)
   at eval code (eval code:1:29)
   at ./lib/jsonld.js (eval code:294:1)
   at __webpack_require__ (eval code:25:12)
   at eval code (eval code:9:1)
   at Anonymous function (eval code:2180:1)
   at __webpack_require__ (eval code:25:12)
   at Anonymous function (eval code:89:11)

I think the syntax error is caused by ES6+ syntax in rdf-canonize, e.g. async function here: https://github.com/digitalbazaar/rdf-canonize/blob/d410a2f6212073b59b8fe51acdb47de53514e66c/lib/index.js#L82

Should rdf-canonize be published in trinspiled form in the NPM package?

@aljones15
Copy link
Contributor

Have you tried a polyfil?

https://github.com/YuzuJS/setImmediate
That's one of several.

I'm a bit surprised we don't use one. Thanks for the update.

@AlexeyMz
Copy link
Author

AlexeyMz commented Jul 9, 2019

It will probably work with polyfill in Edge but at the same time won't solve syntax error from rdf-canonize in IE 🙁

@dlongley
Copy link
Member

setImmediate has been removed from jsonld.js -- closing.

@davidlehn
Copy link
Member

@dlongley setImmediate is still in rdf-canonize. Is there a more modern construct that would allow that to be removed? This should perhaps stay open until that is addressed.

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

4 participants