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

"Maximum call stack size exceeded" when create many Proxy instance using same handler #2206

Closed
link89 opened this issue Jan 3, 2020 · 2 comments · Fixed by #2207
Closed
Labels
Milestone

Comments

@link89
Copy link
Contributor

link89 commented Jan 3, 2020

Hi, we found that there is a chance that when using testcafe to test a mbox based SPA, "Maximum call stack size exceeded" error will occur during case execution.

It turns out the root cause of this error is because hammerhand overwrite window.Proxy.
Here is a minimal reproduce script

const handler = {
    get: function(obj, prop) {
        return prop in obj ?
            obj[prop] :
            37;
    }
};
let p;
for (let i = 1; i < 100000; i++) {
    p = new Proxy({}, handler);
}
console.log(p.a)

Start hammerhand play ground and visit any website in it, then execute the code in console, you will get this error:
微软_Bing_搜索_-_国内版

Here is the related code

        if (window.Proxy) {
            window.Proxy = function (target, handler) {
                if (handler.get) {
                    const storedGet = handler.get;

                    handler.get = function (getterTarget, name, receiver) {
                        if (name === IS_PROXY_OBJECT_INTERNAL_PROP_NAME)
                            return IS_PROXY_OBJECT_INTERNAL_PROP_VALUE;

                        return storedGet.call(this, getterTarget, name, receiver);
                    };
                }

                return new nativeMethods.Proxy(target, handler);
            };
            window.Proxy.toString = () => nativeMethods.Proxy.toString();
            window.Proxy.revocable = nativeMethods.Proxy.revocable;
        }

I guess this bug can be fixed by checking if the handler has already been overwrite.

@Dmitry-Ostashev
Copy link

Thank you for your report and PR. We'll discuss it.

@lock
Copy link

lock bot commented Jan 24, 2020

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked Issues that were automatically locked by the Lock bot label Jan 24, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants