You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
External dependencies sometime are not yet loaded #597
Unfortunately it's very hard to synchronise loading of external resource scripts with sandbox code execution. A workaround would be to wait for the script to load (in this particular case, wait until the global instantsearch is available on window) before running your code.
Hi @lbogdan I never imagined it to be hard frankly because I don't know the internal code of the loading at all. But I thought since those are just script tags it could be achieved (again I am sure this is hard yes). For our own usecase yes we can find workarounds like using actual npm imports but I guess most people using external dependencies will have the same issue.
Maybe for now since it's unstable and requires workarounds that are not documented/hard to implement (wait until x) we should hide this feature? I expected it to work flawlessly.
Hmm, I think this should work without a workaround regardless. I was expecting that it would work on an event, I can fix this with this PR #702. Let's keep it open until that one is merged in.
@CompuIves Wouldn't this working imply the sandbox was started (actually it's already started when handleExternalResources() is called, so it's more like "the sandbox was paused until") after all the external scripts are loaded and evaluated? From what I can see in external-resources.js, they're just added to <head>, and then it's the browser's job to load and evaluate them, which is async to the sandbox continuing running.
Activity
lbogdan commentedon Apr 28, 2018
Hey @vvo ,
Unfortunately it's very hard to synchronise loading of external resource scripts with sandbox code execution. A workaround would be to wait for the script to load (in this particular case, wait until the global
instantsearchis available onwindow) before running your code.I made a naive example implementation here https://codesandbox.io/s/wk26r3qo3l , please take a look and let me know what you think.
vvo commentedon May 15, 2018
Hi @lbogdan I never imagined it to be hard frankly because I don't know the internal code of the loading at all. But I thought since those are just script tags it could be achieved (again I am sure this is hard yes). For our own usecase yes we can find workarounds like using actual npm imports but I guess most people using external dependencies will have the same issue.
Maybe for now since it's unstable and requires workarounds that are not documented/hard to implement (wait until x) we should hide this feature? I expected it to work flawlessly.
Thanks!
CompuIves commentedon May 15, 2018
Hmm, I think this should work without a workaround regardless. I was expecting that it would work on an event, I can fix this with this PR #702. Let's keep it open until that one is merged in.
lbogdan commentedon May 15, 2018
@CompuIves Wouldn't this working imply the sandbox was started (actually it's already started when
handleExternalResources()is called, so it's more like "the sandbox was paused until") after all the external scripts are loaded and evaluated? From what I can see in external-resources.js, they're just added to<head>, and then it's the browser's job to load and evaluate them, which is async to the sandbox continuing running.CompuIves commentedon May 20, 2018
Fixed in master, will be deployed either this evening or tomorrow morning.
vvo commentedon May 23, 2018
You 🤘