Name the push verification entry absolutely, from both sides
A JMAP push subscription stays silent until the client echoes back a verification code. When the code arrives with no tab open, the service worker leaves it in the cache for the next tab to collect. Both sides named that entry relatively, and a relative key is resolved against the URL of whoever is asking. The worker lives at <base>/sw.js, so it wrote under <base>/; a tab at /mail/inbox/abc looked under /mail/inbox/. They agreed only when the open page happened to be the root, which is why this survived: the case that works is the one people try first. The failure is quiet in the worst way. A subscription that never gets its code back simply never delivers, which is indistinguishable from push not working at all -- there is no error anywhere to notice. Both sides now build the key from the mount: the worker from the BASE it already derives from its own location, the page through withBase. Found while adding BASE_PATH, where the two disagree at every route rather than only at deep ones; left alone then because it was pre-existing and unrelated to that change.
This commit is contained in:
+12
-1
@@ -74,7 +74,18 @@ self.addEventListener("fetch", (event) => {
|
||||
* credentials), so it is stashed for a tab to collect and confirm.
|
||||
*/
|
||||
|
||||
const VERIFY_KEY = "ihasmail-push-verification";
|
||||
/*
|
||||
* Absolute, and anchored to the mount rather than to whatever page happens to
|
||||
* be open.
|
||||
*
|
||||
* A relative key is resolved against the URL of whoever is asking: the worker
|
||||
* lives at `<base>/sw.js`, so it stored this under `<base>/…`, while a tab at
|
||||
* `/mail/inbox/abc` looked for it under `/mail/inbox/…`. The two only ever
|
||||
* agreed when the open page was the root, so a verification code that arrived
|
||||
* with no tab open was written where the next tab would not look -- and the
|
||||
* subscription stayed silent, which is the same thing push failing looks like.
|
||||
*/
|
||||
const VERIFY_KEY = `${BASE}/ihasmail-push-verification`;
|
||||
|
||||
function textOf(email) {
|
||||
const from = email?.from?.[0];
|
||||
|
||||
Reference in New Issue
Block a user