gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitedb7c947edb7c947calendar: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 56+4 failing → 60 passedmreedb7c947/reports/P1-twice.md

5.0 KB

  1. # P1 — a calendar reminder shown TWICE on the creator's Android Chrome, and ~5 min late
  2. ## Evidence (live log of byrodin, read only; backup copy of 2026-10-22 19:47, deleted afterwards)
  3. - The live log has ONE `push sent (201) for 0mvkoh019mjp:1792758600000` at 2026-10-23 12:30:23.857 UTC. The key's instant is
  4. 12:30:00 UTC (= 14:30 Vienna). The event id was created 07:58 UTC the same day. The server therefore sent ONE push to ONE subscription,
  5. 23 s after the due time (the clock ticks every 30 s; the tick before, 12:29:53, had nothing due). **The server scheduler is not the 5 minutes**:
  6. at most 30 s late by design; the rest is delivery (FCM / Doze / the phone) or the page.
  7. - No `push not sent` line; the only other push line in 24 h is `push test sent (201)` 2026-10-22 15:44. The server restarted once
  8. (container up 21 h, two "listening" lines 3 s apart are the deploy's up + restart, one process).
  9. - Subscription table (backup copy, 22 Oct 19:47 — the newest backup; it predates the event): ONE live row, owner `0muh8y8myb5z`
  10. (the creator; the event owner id), endpoint host `fcm.googleapis.com`, zone Europe/Vienna, created 2026-10-22 15:48:23 UTC,
  11. since 17:46:43 UTC (moves every 30 s), test 0. The older row `0mvj6lex2l83` (created 06:49 UTC) was deleted at 15:44 (a 410 after the browser rotated
  12. its subscription). So no second subscription of the same device; a second *send* path is excluded by the log (one line). The live table could not be read.
  13. - Service worker: ONE `push` listener (workerEntry in WebFramework.hl) → `pushed()` → one `showNotification(tag = key)`. One registration, scope `/`
  14. (`pushSubscribe` registers the same entry script at the same scope; the page's `getRegistration()` is that one). `testRound`/test path: one line only on 22 Oct.
  15. ## Cause found (ours, proven in real headless Chrome): the PAGE shows the reminder twice by itself, and again after the push
  16. `month-view.hl arm()` shows the reminders that came due while the page could not run ("missed", also the late 5 min case: a frozen/dropped Android tab
  17. comes back) and sets the timers. It is called from FIVE places that all fire when a tab is shown again: `browserEnv` end, `pageshow`, `visibilitychange`,
  18. `takeSoon` (the server's answer), the 10-minute `monthEnv`. Its `notify` calls wait for the browser, and `remember(now)` comes AFTER them, so the second
  19. call (2 ms later) starts with the same `since` and shows the same reminder again (and a run interleaved with another leaves timers behind that are never cleared).
  20. Measured on the old tree (tests/push-twice.mjs, control "bob", no push): `showNotification` called TWICE for one missed reminder, 1–2 ms apart,
  21. same tag. Chrome on Android shows a same-tag repost as a new alert; with the push (tag the same, 23 s after) a third post.
  22. Second, independent path: the server pushed the reminder (shown on the phone, then tapped / swiped away), then the page opens
  23. and `arm()` shows the SAME reminder again as "missed" — the page only knows its own localStorage, not that the server already pushed it
  24. (old tree, "alice": the page re-showed it, twice). A same-tag repost only replaces a notification that is still shown.
  25. That together = "twice, and late": the push (or nothing on time while the phone dozed), then the tab thawing at ~5 min.
  26. What I cannot prove from here: why the phone showed it ~5 min late (FCM delivery under Doze / battery saver, or the thawed page: both end in the same page code).
  27. ## Fix (all .hl, commit on p1-twice)
  28. - `arm()` runs one at a time (`arming` / `armAgain`; a call that comes while one runs makes it run once more afterwards).
  29. - `lib/push.hl pushedUntil` + face `calPushedUntil` (calendar.hl): up to when the server has handled this device's reminders (its `since`, only if the server
  30. looked in the last 15 min). The page's `pushedSince` raises its "missed" start to that. No subscription / no answer / server stale → as before (the net stays).
  31. - Gate `tests/push-twice.mjs` (in deploy.sh GATES): 1 server pushes once to the closed device; 2 the reopened page shows NOTHING of it; 3 control: a device
  32. without push still gets its missed reminder from the page, EXACTLY once. On the old tree: 3 passed, 2 failed (2 and 3: two `showNotification` calls each).
  33. ## Gates
  34. browser 86 passed; theme 0 problems; notify-paths 7 passed (3 known Hybriel gaps); push 30 passed; push-twice 5 passed (old tree: 3 passed, 2 failed); dst 13 passed. Ports 8700–8719.
  35. ## What the creator should check on the phone (if it still happens after the deploy)
  36. - Chrome → the calendar site → Settings → Notifications: the calendar must exist ONCE (not also as an installed app / second "Calendar" entry; an installed
  37. PWA and a Chrome tab share the worker, but two entries mean two channels that each show a copy).
  38. - Android: Settings → Apps → Chrome → Battery: "Unrestricted" (not Optimized/Restricted), and no battery saver; Chrome → Site settings → the calendar:
  39. Notifications allowed. Doze delays push for Chrome when restricted — that is the ~5 minutes.
  40. - Reminder settings in the calendar: "Turn off on this device", then "Turn on notifications" once (a clean single subscription).

Branches

Latest commits

  • edb7c947calendar: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 56+4 failing → 60 passedmre
  • bf8cc0fcStyles move into their components: the shell's styles into main.hl, the events and the editors into the month view's Style block; styles.hl keeps only the theme inherit, the accent and the message line; .gitignore ignores a bin symlink too; tests/styles-shots.mjs for the before/after pixel comparemre
  • 5d8579d7README: login.js stays by caramboleyo's explicit rulemre
  • cc759328Merge sb3-standby: calendar deploys through its standbymre
  • f2fcdc6dcalendar: a standby container (port 45015, profile standby, reminder clock off) and a /health page; deploy hands over through standby-swap.sh without a gapmre
  • 229643f7Merge branch 'cal-14'mre
  • 1110b26fcalendar#14: the month name no longer breaks into two lines on a phone (Reminder settings drops to its own row when the header is too narrow), gate checks for one-line title and all header controls on screenmre
  • 490c658aident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
  • 18095868calendar: Reminder settings button opens its dialog again (the dialog's open handler still closed the removed user menu and stopped); old e2e and gate scripts use the new headermre
  • 6eee4b5acalendar header: the selector alone top right plus Log out as before the theme missions; Reminder settings back on the month page (WIP: the settings test still fails)mre
  • 0b909decident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
  • 0c8f9364Merge branch 'sy-sync'mre
  • 9fab1c8fsync components.hybriel 4922f9c into the month view: prev / next 44 px targets, names formatted in UTC (a UTC+12 zone showed the wrong first weekday); the calendar keeps its own language handling (Accept-Language / browser) and the P1/C13 reminder code; gate: 44 px check (SY)mre
  • 27d3e294theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 2ac9c1bbdeploy: security gate (tests/security.mjs)mre
  • 6b0a2571merge sc-sec (calendar security) with 99-year sessionsmre
  • 92001e52sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • 0f76c99dSecurity audit SC: push endpoint SSRF guard, uploadMax 0, Secure cookie, login session rotation + rate limit, event cap, nosniff, security gatemre
  • 2dd53dccP1: one reminder shows once: arm() one at a time, the page skips reminders the server already pushed; push-twice gatemre
  • 3a29760aC13 report (handoff)mre