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

service-worker: await unnecessary, errors should be handled #254

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sidewayss
Copy link
Contributor

@sidewayss sidewayss commented Feb 3, 2024

Pretty simple stuff, minimal code changed. await as the last command in a function is pointless. Errors thrown during the completion of a promise should be handled. Low probability of errors in this project as-is, but high probability of errors for any newbie adapting this example for their own project.

The two calls to caches.match() could use similar .catch() blocks, but I left them alone for now. They're easy enough to add before merging if you all decide to include them.

Copy link

@skyclouds2001 skyclouds2001 left a comment

Choose a reason for hiding this comment

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

The original function is intended to throw the exception to the outside where the function is called, whether its thrown exception should be handled or not completely decided by outside caller.
The fix make it outside caller unable to handle it any more.

Another issue is that the original function will end only when the put execution ends, but the fix make the outside caller unable to detect when function ends.

So I believe the fix is not correct and should be closed.

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.

2 participants