Skip to content

Commit 42edfc1

Browse files
committed
fix(ui): detect gateway scope errors structurally, not by class identity
Under isolate:false a custom element registered by an earlier test file keeps its own module registry, so instanceof GatewayRequestError diverges while the error shape stays stable; the branch's new custodian test files reshuffled worker packing and exposed this in usage-page.test.ts.
1 parent c9017e2 commit 42edfc1

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎ui/src/lib/gateway-errors.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// Control UI shared Gateway error helpers.
22
import { ConnectErrorDetailCodes } from "../../../packages/gateway-protocol/src/connect-error-details.js";
3-
import { GatewayRequestError, resolveGatewayErrorDetailCode } from "../api/gateway.ts";
3+
import { resolveGatewayErrorDetailCode } from "../api/gateway.ts";
44

55
export function isMissingOperatorReadScopeError(err: unknown): boolean {
6-
if (!(err instanceof GatewayRequestError)) {
6+
// Structural check, not instanceof: under isolate:false a custom element
7+
// registered by an earlier test file keeps its own module registry, so class
8+
// identity diverges while the error shape (name + details) stays stable.
9+
if (!(err instanceof Error) || err.name !== "GatewayRequestError") {
710
return false;
811
}
9-
const detailCode = resolveGatewayErrorDetailCode(err);
12+
const detailCode = resolveGatewayErrorDetailCode(err as { details?: unknown });
1013
// AUTH_UNAUTHORIZED is the current server signal for scope failures in RPC responses.
1114
// The message-based branch catches responses that do not include a structured detail code yet.
1215
return (

0 commit comments

Comments
 (0)