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

Should importScripts() detect loops or otherwise abort after too much depth? #1570

Open
mfalken opened this issue Mar 8, 2021 · 1 comment

Comments

@mfalken
Copy link
Member

mfalken commented Mar 8, 2021

Chrome apparently crashes if sw.js tries to do importScripts(sw.js): https://crbug.com/1180572

This was previously discussed a little at #1041 (comment).

Should importScripts() do something more intelligent than crashing.

@jakearchibald suggested that iframes may have a protection against nesting iframes of the same URL, that we can learn from. cc @wanderview

@wanderview
Copy link
Member

This should be easier than the iframe case. Iframes load asynchronously, but importScripts() is synchronous. So we can keep a stack of currently loading scripts and just check if the current script is already loading once already. If so, throw an exception as a loop was detected.

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

2 participants