Sinon.js out of memory error on ie8

187 views
Skip to first unread message

jk01

unread,
Jul 12, 2012, 10:58:13 AM7/12/12
to sin...@googlegroups.com
Got this error when running sinon unit test in browser or just by trying to open a html file with sinon.js and sinon-ie.js files included. Anyone saw this too?

Thanks,

jk

jk01

unread,
Jul 12, 2012, 11:47:22 AM7/12/12
to sin...@googlegroups.com
I think I found the bug in stub.js causing this:

stub.js:299

        // create asynchronous versions of callsArg* and yields* methods
        for (var method in proto) {
            if (proto.hasOwnProperty(method) && method.match(/^(callsArg|yields)/)  {
                proto[method + 'Async'] = (function (syncFnName) {
                    return function () {
                        this.callbackAsync = true;
                        return this[syncFnName].apply(this, arguments);
                    };
                })(method);
            }
        }

Here, a new method with name  'methodAsync' is added to the prototype every time a good match is found, causing the for loop to loop forever. Wondering, why this happens in ie8 only.

The fix could look like:
            ...
            if (proto.hasOwnProperty(method) && method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
            ...
I am going to fill a pull request if you are fine with this.

Please, let me know.

Thanks.

Jan

Christian Johansen

unread,
Jul 15, 2012, 4:53:38 PM7/15/12
to sin...@googlegroups.com

Oh, wow, nice catch. Please, file the pull request.

Christian

David McCuskey

unread,
Jul 24, 2012, 3:48:23 PM7/24/12
to sin...@googlegroups.com
thanks for the fix ! just today i ran into this problem and found your solution.

cheers,
david

Jan Kopriva

unread,
Jul 24, 2012, 4:01:47 PM7/24/12
to sin...@googlegroups.com
Glad it helped :)

jk

Dave the Ninja

unread,
Oct 4, 2012, 4:41:23 AM10/4/12
to sin...@googlegroups.com
I also have encountered this... IE8 was running at 10.4 GB ram :-)

Has a patch been submitted for this already? as was about to submit a pull request for exactly the same fix.

Dave

Christian Johansen

unread,
Oct 4, 2012, 4:48:52 AM10/4/12
to sin...@googlegroups.com
Which version are you on?
--
MVH
Christian

David Lawton

unread,
Oct 4, 2012, 4:51:03 AM10/4/12
to sin...@googlegroups.com
8

Christian Johansen

unread,
Oct 4, 2012, 4:55:51 AM10/4/12
to sin...@googlegroups.com
Sinon :)
--
MVH
Christian

Jan Kopriva

unread,
Oct 4, 2012, 5:08:30 AM10/4/12
to sin...@googlegroups.com
Hi,

yes, it's been integrated already.

Jan

David Lawton

unread,
Oct 4, 2012, 5:09:18 AM10/4/12
to sin...@googlegroups.com
Hahahah latest version 1.4.2

David Lawton

unread,
Oct 4, 2012, 5:10:06 AM10/4/12
to sin...@googlegroups.com
Ok thanks. Pulled latest and its there. 

Thanks again
Reply all
Reply to author
Forward
0 new messages