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

fix: prevent SW exception #5985

Merged
merged 2 commits into from
Mar 10, 2024
Merged

fix: prevent SW exception #5985

merged 2 commits into from
Mar 10, 2024

Conversation

gioboa
Copy link
Member

@gioboa gioboa commented Mar 9, 2024

This fix will solve this edge case error.
With:

  • empty browser cache
  • no active service worker

sometimes the variable $cache$ is null when that code is evaluated.

Pasted image 1
Pasted image

This code could be the problem https://github.com/BuilderIO/qwik/blob/157f7b01df22448638f7cc55546a051aa4eea5f0/packages/qwik/src/prefetch-service-worker/setup.ts#L42

Copy link

netlify bot commented Mar 9, 2024

👷 Deploy request for qwik-insights pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 08d8f97

@@ -79,8 +79,8 @@ function taskTick(swState: SWState) {
if (task.$isFetching$) {
outstandingRequests++;
} else if (
outstandingRequests < swState.$maxPrefetchRequests$ ||
task.$priority$ >= DIRECT_PRIORITY
swState.$getCache$() &&
Copy link
Member Author

@gioboa gioboa Mar 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents swState.$put$ without cache in place

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you await that?

Copy link
Member Author

@gioboa gioboa Mar 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gioboa gioboa merged commit 6b6b3ac into QwikDev:main Mar 10, 2024
23 checks passed
@gioboa gioboa deleted the fix/prefetch-sw branch March 10, 2024 19:10
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

Successfully merging this pull request may close these issues.

None yet

2 participants