-
Notifications
You must be signed in to change notification settings - Fork 12
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
Does icon validity check trigger a SW's fetch handler? #20
Comments
What's an invalid URL in this case? I can't see the sample code, and any string would be resolved with the SW's origin.
Fetching the icon doesn't bypass the service worker (it's implied in the spec by not explicitly mentioning the SW should be skipped, and the same goes for the chromium implementation). So you are calling index.add from within the fetch handler? Grabbing the icon will also call the fetch handler. There might be some weirdness happening there. This might be easier to diagnose if you share a snippet. |
Okay, it's good to know that the SW's You can reproduce the failure by adding https://5de91c72daa70d9982fb68e9--stoic-kepler-c046f7.netlify.com/ to your homescreen and sharing an image from another Android app to it. That will trigger the The underlying service worker is https://5de91c72daa70d9982fb68e9--stoic-kepler-c046f7.netlify.com/service-worker.js, and I turned off some minification to help make it clearer. When you attach DevTools from a desktop Chrome instance and inspect, you'll see a failure along the lines of That shows the icon request not hitting the |
I can confirm that the icon check will trigger the service worker's In https://5de92abbb4ad155265985054--stoic-kepler-c046f7.netlify.com/ I've moved the calls to The relevant code is https://github.com/jeffposnick/samples/blob/72b8b334b0bd45e51cd553d75af07572d58be09a/web-share/src/js/contentIndexing.js#L20-L53 for those who are curious. The explainer doc currently includes a couple of examples of calling Hardcoding |
This might be less of a bug against the spec and more of an implementation detail related to Chrome 80's current behavior.
registration.index.add()
currently rejects if you pass in anicons[].src
value that isn't a valid URL. I'm curious about how this determination is made, as it's making it difficult for me to accomplish something while trying out the Content Indexing API. (Sample code.)I've got a PWA that handles incoming media sharing requests using the Web Share Target API on Android.
If a user shares an image to my PWA, that image gets saved locally using the Cache Storage API with a cache key URL that doesn't exist on a remote server—requests for that URL will only succeed if intercepted by my service worker's
fetch
event handler, which will bypass the network and return the cached media resource.I am calling
registration.index.add()
inside of the samefetch
handler that is responsible for handling the incomingPOST
request from the Web Share Target API. If I pass in anicons[].src
value corresponding to a generic icon URL that exists on the remote server, everything works as expected. However, if I pass in aicons[].src
value that refers to the newly-cached image (which, again, is only valid when intercepted by the service worker, and doesn't exist on the remote server), theadd()
call rejects due to an invalid icon.I can probably refactor things so that the call to
registration.index.add()
happens outside of afetch
handler, if that's what's causing the failure. But my bigger question is whether the validity checks for icons is supposed to trigger a service worker'sfetch
handler at all—because if it doesn't, I've got a bigger issue to solve.The text was updated successfully, but these errors were encountered: