mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-11-05 11:39:24 +09:00
Look the endpoint up past the query cache, and keep a subscription a race refused
The lookup under the write lock repeated the one made before validation, so the query cache could answer it with that earlier miss even after another connection had registered the endpoint. It runs uncached now. Enabling notifications unsubscribed the browser on any refusal, so a session signed out between authenticating and saving lost the browser's subscription too, and the next session had nothing to post. Only a refused endpoint unsubscribes it now.
This commit is contained in:
1 parent
3786ee5244
commit
aa93269ceb
3 files changed
+42
-9
No files matched your search
@@ -106,7 +106,8 @@ export default class extends Controller {
|
||||
|
||||
async #syncPushSubscription(subscription) {
|
||||
const response = await post(this.subscriptionsUrlValue, { body: this.#extractJsonPayloadAsString(subscription), responseKind: "turbo-stream" })
|
||||
if (!response.ok) subscription.unsubscribe()
|
||||
// Only a refused endpoint is for good. A session signed out mid-request posts it again after signing in.
|
||||
if (response.unprocessableEntity) subscription.unsubscribe()
|
||||
}
|
||||
|
||||
async #requestPermissionAndSubscribe(registration) {
|
||||
|
||||
Reference in new issue
Block a user