Stop reporting gateway errors as CLI crashes - #8329
Conversation
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationspackages/cli-kit/dist/private/node/api/gateway-status.d.ts/**
* Pure helpers for classifying HTTP statuses that come from the gateway in front of an API rather
* than from the API itself.
*
* This module is intentionally dependency-free: it is imported by both the request layer
* (`../api.ts`) and the crash-report suppression logic (`../../public/node/error.ts`).
* `error.ts` cannot import `../api.ts` directly — that would pull `graphql-request` into the
* module graph of every command, and `api.ts → headers.ts → error.ts` is already a cycle — so the
* shared status logic lives here, where it imports nothing from cli-kit.
*/
/**
* Whether an HTTP status indicates a gateway-level failure in front of the API.
*
* @param status - The HTTP status of the response, if known.
* @returns True when the status is 502, 503 or 504.
*/
export declare function isGatewayErrorStatus(status: number | undefined): boolean;
Existing type declarationspackages/cli-kit/dist/private/node/api.d.ts@@ -12,6 +12,7 @@ export type NetworkRetryBehaviour = {
type RequestOptions<T> = {
request: () => Promise<T>;
url: string;
+ requestIsIdempotent?: boolean;
} & NetworkRetryBehaviour;
/**
* Checks if an error is a transient network error that is likely to recover with retries.
|
Assisted-By: devx/cfa7efa4-831b-4142-a418-5480cf27ac8c
6163b9c to
c2e3f30
Compare
|
Reviewed in the context of resolving Vault 68247 / shop/issues#73647, which this PR targets. No merge-blocking issues — this looks correct and I'd land it. Two things I verified rather than assumed:
Non-blocking notes:
For context on why it's worth unblocking: the error has been re-firing since this PR went up on Aug 14 — 37 events / 35 users in the last 7-day window on the theme path alone. |
Raw
graphql-requestClientErrorobjects can reach the top-level reporter when a call site useshandleErrors: false. For HTTP 502, 503, and 504, that records an infrastructure failure as an unexpected CLI bug.Classify these gateway statuses as expected in
shouldReportErrorAsUnexpected, consistent with the handled path that maps 5xx responses toAbortError. HTTP 500 keeps its existing classification.Testing
pnpm --filter @shopify/cli-kit vitest run src/public/node/error.test.tspnpm --filter @shopify/cli-kit type-check