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

web workers - import() is not cached? #21035

Open
bebraw opened this issue Nov 1, 2023 · 0 comments
Open

web workers - import() is not cached? #21035

bebraw opened this issue Nov 1, 2023 · 0 comments

Comments

@bebraw
Copy link

bebraw commented Nov 1, 2023

I noticed something weird while working on Gustwind, my Deno based tool meant for creating websites.

To make the approach more flexible, I began to leverage import() to fetch remote resources (in this case, components and their code). For performance purposes, the tool leverages web workers.

It seems this particular combination is triggering some behavior in Deno that's not exactly expected as it seems that during a build it's fetching remote resources separately each time for each worker instead of leveraging a shared cache. I understand there's some potential for a race condition there but at least after the first import() that completed I would expect it to be fast at least on a subsequent build.

I set up a branch to show the issue. If someone wants to check it, here's how to do it:

  1. Check out https://github.com/gustwindjs/gustwind/tree/worker-import-bug
  2. deno task build
  3. While it's building, note that it's pointing to a remote resource every once in a while

The builder code is located at https://github.com/gustwindjs/gustwind/tree/worker-import-bug/gustwind-builder and the loader is at https://github.com/gustwindjs/gustwind/blob/worker-import-bug/utilities/loaders.ts (this is doing import()).

If you want, I can try to come up with a greatly simplified example but I thought to open this issue to see if it's expected behavior instead of a bug. I suppose I could try to avoid import() and go with fetch() and my own approach instead but the problem there is that I would have to pull dependencies as well (doable but it's some work since this implies AST introspection and traversing a dependency graph and caching everything. Now Deno is doing all the work for me).

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

1 participant