What Causes the Error "Can't Execute Code from a Freed Script"

Why do I get Can't execute code from a freed script

This question contains a good answers about iframes relationship.
(Added as answer by OP suggestion).

Angular 4 app using IE 11, Can't execute code from a freed script

One solution is to set the variable isEnableCrossContextCheck to true, so that IE should run the code containing a try/catch block, which can handle the error.

        if (isEnableCrossContextCheck) {
try {
var testString = delegate.toString();
if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) {
nativeDelegate.apply(target, args);
return false;
}
}
catch (error) {
nativeDelegate.apply(target, args);
return false;
}
}
else {
var testString = delegate.toString();
if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) {
nativeDelegate.apply(target, args);
return false;
}
}

This post shows how to to that:

Angular 4 put a global constant available to zone.js

Can't execute code from a freed script

I figured out the solution.

Basically, you take all of the code I previously posted, and the execute it from within the context of the target frame using the eval() function. So...

myFrame.eval("SomeFunction = (function () {var originalSomeFunction = SomeFunction; return function (arg1, arg2, arg2) {alert('Inside override!'); originalSomeFunction(arg1, arg2, arg3);};})();");

Because the code is now within the target frame, it doesn't go out of scope, and we don't get the "freed" error anymore.

IE9 Can't execute code from freed script when calling hasOwnProperty()

Just ran into a similar issue. For me, simply changing s1data.hasOwnProperty('prop1') into ('prop' in s1data) made the error go away.

Can't execute code from a freed script - IE6 IE7 IE8 IE9

First of all you need to locate the source of the message.

IE is known for it's abysmal error reporting but luckily IE9 seems somewhat capable. If this bug occurs in IE6, IE7 or IE8 it will also occur in IE9, so use IE9 to debug (for your sanity)

Open the webdeveloper console in IE9 (press F12) and run through the steps to produce this error.

IE9 should now give you a file and line indication on the console, yay!

What typically goes wrong is a callback that is executed after some delay, either by setTimeout or because of an Ajax request. If the window, document or frame the callback is defined in got unloaded then you will get this message when it tries to execute your callback function.

Seemingly other browsers ignore this problem, which is fine I guess. To make IE do the same just wrap the callback in a try-catch block (I don't know what the callback would evaluate to, I don't think it evaluates to undefined). If you want have more precise error handling or if you actually want to take action when this occurs you can probably do so and please make a post here because I'm curious as to what kind of use case would actually require this.

Can't execute code from a freed script when calling date.getHours() in IE9

In my experience, the problem happens when the Date object you've got was constructed in a different window, such that since its construction that other window has been closed or reloaded with a new page.

The solution is to send object inter-window in some string form, reconstituting them as necessary in the destination context.

(It isn't just Date instances of course; it's any object type. Primitives don't have the problem, if I recall.)



Related Topics



Leave a reply



Submit