angular: [BUG] IE11 -> Can't execute code from a freed script

Context:

  • angular 5.0.0-rc3
  • zone.js 0.8.18
  • IE 11

I tried to update from zone 0.8.4 (current official angular 5 tutorials version) to 0.8.18, and get at some point with IE 11 the following error: Can't execute code from a freed script. This is a really imprecise error, that I didn’t manage to find the origin but is due for sure from zone.js.

EDIT: after testing => appear from 0.8.12 (working) to 0.8.13 (no more working on IE 11)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 20
  • Comments: 39 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I seem to get this error in IE11 while dev tools are open, regardless of whether or not JiaLiPassion’s fix is applied. Closing dev tools makes the web app load again… gotta love IE

@ganeshkbhat, @falcoprescher , could you guys try to add

<script>
__Zone_enable_cross_context_check = true;
</script>

in index.html before loading zone.js?

@shcallaway , oh, sorry, please modify it to

(window as any).__Zone_enable_cross_context_check = true;
import 'zone.js/dist/zone';  // Included with Angular CLI.

Thanks so much @JiaLiPassion

Added only for IE and Edge using the below in pollyfills.ts and it works a charm

/*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*/
//(window as any).__Zone_enable_cross_context_check = true;
if (document['documentMode'] || /Edge/.test(navigator.userAgent)) {
    (window as any).__Zone_enable_cross_context_check = true;
}

@lifaon74 , glad to help, and __Zone_enable_cross_context_check this flag will enable some additional error check to IE, in IE, sometimes DeveloperTools will also register eventListeners which will cause some weird exceptions.

I took the example from https://github.com/mgechev/angular-seed , and updated to angular 5 and zone.js 0.8.18. I added you code and this worked ! Do you have detailed informations of what does this module (https://github.com/angular/zone.js/blob/master/MODULE.md) ? And idea why does it works on chrome but not on IE ?

Thanks to you.

EDIT 1 : the error is in zone.js inside checkIEAndCrossContext at line 2747 EDIT 2 : the bug is sometimes hard to reproduce as it does not append everytime

Same Issue here

@jochenhebbrecht , yes, everything will work if you set it to true. enable the flag will cause an additional try/catch and toString operation when you call addEventListener. so it will be a little performance impact when you call addEventListener, the behavior is the same.

And the reason don’t want to set it to true by default even in IE because it only impact some of the developer tools , so it only impact development mode, and in the new version of angular/cli generated project, you can find the following code in src/polyfills.ts.


 /*
 * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
 * with the following flag, it will bypass `zone.js` patch for IE/Edge
 */
// (window as any).__Zone_enable_cross_context_check = true;

you can open the comment when you in development mode and comment it when you want to build in production mode.

@fuerst, @ciesielskico, you can just add the following line in polyfill.ts before loading zone.js.

(window as any).__Zone_enable_cross_context_check = true;
import 'zone.js/dist/zone';  // Included with Angular CLI.