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

navigation requests w/ StaleWhileRevalidate + broadcastUpdate = TypeError: Deferred_mjs.Deferred is not a constructor #2045

Closed
johnrobertcobbold opened this issue Apr 26, 2019 · 3 comments · Fixed by #2050
Assignees
Labels
Bug An issue with our existing, production codebase. workbox-broadcast-update workbox-core

Comments

@johnrobertcobbold
Copy link

Library Affected:
workbox-broadcast-cache-update

Browser & Platform:
Chrome

Issue or Feature Request Description:
When trying to use workbox-broadcast-cache-update for navigation requests using the StaleWhileRevalidate for which there is an update (using the Last-Modified header), I get the following error:

Uncaught (in promise) TypeError: Deferred_mjs.Deferred is not a constructor
    at BroadcastCacheUpdate._windowReadyOrTimeout (BroadcastCacheUpdate.mjs:154)
    at sendUpdate (BroadcastCacheUpdate.mjs:106)
    at BroadcastCacheUpdate.notifyIfUpdated (BroadcastCacheUpdate.mjs:112)
    at Plugin.cacheDidUpdate (Plugin.mjs:80)
    at Object.putWrapper [as put] (cacheWrapper.mjs:99)

I am already using workbox-broadcast-cache-update with native Fetch API requests on loaded pages and it's working great. Something to do here with the page not being loaded? Is there a workaround or is there is no way to use BroadcastCacheUpdate for navigation requests?

@jeffposnick
Copy link
Contributor

It looks like it's this line that triggers the error:

@philipwalton, is this potentially due to some class name mangling introduced by minification?

@jeffposnick jeffposnick added Bug An issue with our existing, production codebase. workbox-broadcast-update workbox-core labels Apr 29, 2019
@philipwalton
Copy link
Member

Hmmm, it looks like the Deferred object is never exported from workbox-core/_private.mjs: https://github.com/GoogleChrome/workbox/blob/v4.3.0/packages/workbox-core/_private.mjs#L22-L32

And this passes our unit tests because we do a custom build for those, so I guess we don't cover this code path in our integrations tests.

We should probably also separately have a test to ensure _private symbols are properly exported, as this is sort of one-off logic in our build.

@philipwalton
Copy link
Member

@goyavo the fix for this is in v4.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An issue with our existing, production codebase. workbox-broadcast-update workbox-core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants