Skip to content

External dependencies sometime are not yet loaded #597

Closed

Description

@vvo

On this CodeSandbox preview: https://24zn89jm5p.codesandbox.io/?cities=Boston&productTypes=Speaker

I get:
image

The preview only seems to constantly fail while the editor fails one time out of two.

Shouldn't the dependencies be loaded before the actual sandbox code?

Activity

  1. lbogdan commented on Apr 28, 2018

    @lbogdan
    Contributor

    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 instantsearch is available on window) 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.

  2. vvo commented on May 15, 2018

    @vvo
    Author

    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!

  3. CompuIves commented on May 15, 2018

    @CompuIves
    Contributor

    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.

  4. lbogdan commented on May 15, 2018

    @lbogdan
    Contributor

    @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.

  5. CompuIves commented on May 20, 2018

    @CompuIves
    Contributor

    Fixed in master, will be deployed either this evening or tomorrow morning.

  6. vvo commented on May 23, 2018

    @vvo
    Author

    You 🤘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions