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

Misleading log messages when resource URL has fragment #2323

Closed
aritsune opened this issue Jan 12, 2020 · 0 comments · Fixed by #2371
Closed

Misleading log messages when resource URL has fragment #2323

aritsune opened this issue Jan 12, 2020 · 0 comments · Fixed by #2371
Labels
Developer Experience Related to ease of use for developers. Good First Issue This would be an ideal issue for a new contributor to take on. workbox-routing

Comments

@aritsune
Copy link

aritsune commented Jan 12, 2020

Libraries Affected:
workbox-routing / workbox-precaching

Browser & Platform:
Google Chrome v81.0.4023.0

Issue:
I just spent a while debugging some seemingly strange behavior in my project, which uses the GenerateSW workbox webpack plugin. I had set up a runtimeCaching rule with the URL pattern
/\.(png|jpg|jpeg|svg)$/; yet many SVG files were not being cached as expected. I turned to the verbose-level log & saw several instances of No route found for: /file.svg, which was obviously super jarring - it even happened when I set the URL pattern to the exact file name!
I figured out what was going on only when I set a debugger breakpoint at the line that logs that message - it turns out the real URL that was being matched against had a fragment (i.e /file.svg#content), & the log was obscuring this, I believe due to its use of the getFriendlyURL function:

if (!handler) {
if (process.env.NODE_ENV !== 'production') {
// No handler so Workbox will do nothing. If logs is set of debug
// i.e. verbose, we should print out this information.
logger.debug(`No route found for: ${getFriendlyURL(url)}`);
}
return;
}

(note: I need the fragment because I'm using an svg <use> tag.)

I think URLs are being similarly obscured in workbox-precaching debug logs as well. The solution should be pretty simple - keep URL fragments when logging so the user knows exactly what URL patterns are being tested against.

@jeffposnick jeffposnick added Developer Experience Related to ease of use for developers. Good First Issue This would be an ideal issue for a new contributor to take on. workbox-routing labels Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Related to ease of use for developers. Good First Issue This would be an ideal issue for a new contributor to take on. workbox-routing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants