From 25516ed347db433e0018e42e37a7ef4ebfb43f8f Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 31 Oct 2026 23:53:11 +0100 Subject: [PATCH] refactor: recognise a shared-store outage in the auth routes with the store's own check --- lib/auth/store-unavailable.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/auth/store-unavailable.ts b/lib/auth/store-unavailable.ts index 8d0fdb878..62a0d8d20 100644 --- a/lib/auth/store-unavailable.ts +++ b/lib/auth/store-unavailable.ts @@ -1,5 +1,5 @@ import { NextResponse } from 'next/server'; -import { StoreUnavailableError } from '@/lib/shared-store/types'; +import { isStoreUnavailableError, type StoreUnavailableError } from '@/lib/shared-store/types'; /** * Answers for when the shared store (#1066) can't be reached. Sign-in limits @@ -10,12 +10,9 @@ import { StoreUnavailableError } from '@/lib/shared-store/types'; export const STORE_RETRY_AFTER_SECONDS = 10; -/** - * Also by name: Next gives each bundle its own copy of the error class, and - * the one store on globalThis throws the copy of whichever bundle created it. - */ +/** By name, as every bundle has its own copy of the error class (see isStoreUnavailableError). */ export function isStoreUnavailable(error: unknown): error is StoreUnavailableError { - return error instanceof StoreUnavailableError || (error instanceof Error && error.name === 'StoreUnavailableError'); + return isStoreUnavailableError(error); } export function storeUnavailableResponse(headers: Record = {}): NextResponse {