-
Notifications
You must be signed in to change notification settings - Fork 72
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
Retrying failed to fetch dynamically imported modules #116
Comments
Sure. You could add a query parameter to the URL you're importing. |
@domenic that's easy when not using import maps. But how do I do that when using import maps? As far as I can tell, |
Also, because import maps can't be dynamically changed post resolution, I also can't dynamically change the import map to point to a new URL with a query parameter. |
This use case relies on at the very least a registry "delete" API. Any type of JS registry reflection spec is still a long way off unfortunately. |
@guybedford it seems as though, when using native modules defined in an import map, the best option is to keep track of |
@blittle can you not manage this at the service worker level? That probably seems preferable for these use cases. |
@guybedford generally I would agree, but I think there is still an edge case to handle due to:
Imagine a scenario where the app is loaded for the first time, and no service worker is available. Then for some reason the browser gets intermittent connectivity, and there are subsequent modules defined in the module map that are now failing to load, and no service worker is available intercept. |
@blittle as mentioned I think the best solution is the dependency reflection and registry delete API combination in such a case: import('app').catch(async err => {
if (!isNetworkError(err)) throw err;
unloadModuleAndDependencies(import.meta.resolve('app'));
return import('app');
});t
function unloadModuleAndDependencies (moduleId) {
const deps = ModuleReflect.getDependencies(moduleId);
if (deps) {
ModuleReflect.delete(moduleId);
deps.forEach(unloadModuleAndDependencies);
}
} The above depends on the hypothetical specifications for I didn't realise Service Worker still hasn't solved the first-load attachment case... but I wouldn't bet on the above arriving any sooner :P |
(and in case it isn't clear - |
I think some sort of API like that would make sense. Whether or not it gets
added to the spec, 🤷♀️, but I figure this issue could stay open to
document the use case.
…On Thu, May 16, 2019 at 7:53 PM Guy Bedford ***@***.***> wrote:
(and in case it isn't clear - ModuleReflect is a really really bad
strawman used just for discussion here, and is by no means anything being
discussed or proposed, and likely shouldn't be).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#116?email_source=notifications&email_token=AAL6RFLDHNTLYHKID2OSJ6DPVYF3BA5CNFSM4G76HC6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVTQCXA#issuecomment-493289820>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAL6RFIOSGEV3KL6DXI5M2TPVYF3BANCNFSM4G76HC6A>
.
--
*Bret Little*
Cell: 801-477-7618
|
I am joining this train a bit late, but it's still an issue. |
I'm trying to understand how to resolve the following scenario:
Failed to fetch dynamically imported module
. The app notifies the user that they are offline.If I wasn't using import maps, I could force a retry by adding a query parameter to the URL I'm importing. With module maps, is there any way to retry a module import that has previously failed?
Note: in my scenario above, I could solve the problem by building a wrapper around the native
import()
that keeps track of whether the user is online/offline and prevent a module request from going out unless they are online. But that doesn't resolve all of the scenarios where a module resolution might fail, and the app may want to retry.The text was updated successfully, but these errors were encountered: