From 7b8683f048c043882bf3be943611afa0f33f66b8 Mon Sep 17 00:00:00 2001 From: Henry Fontanier Date: Fri, 17 Nov 2023 17:12:38 +0100 Subject: [PATCH] fix: silence GH rate limiting (#2596) --- .../github/temporal/cast_known_errors.ts | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/connectors/src/connectors/github/temporal/cast_known_errors.ts b/connectors/src/connectors/github/temporal/cast_known_errors.ts index 6600a2fd9371..22f559d9a4b6 100644 --- a/connectors/src/connectors/github/temporal/cast_known_errors.ts +++ b/connectors/src/connectors/github/temporal/cast_known_errors.ts @@ -1,9 +1,9 @@ +import { RequestError } from "@octokit/types"; import { ActivityExecuteInput, ActivityInboundCallsInterceptor, Next, } from "@temporalio/worker"; - export class GithubCastKnownErrorsInterceptor implements ActivityInboundCallsInterceptor { @@ -14,25 +14,15 @@ export class GithubCastKnownErrorsInterceptor try { return await next(input); } catch (err: unknown) { - const maybeGhError = err as { - status?: number; - name?: string; - type?: string; - }; + const maybeGhError = err as RequestError; - if ( - maybeGhError.status === 403 && - maybeGhError.type === "RequestError" && - maybeGhError.name === "HttpError" - ) { + if (maybeGhError.status === 403 && maybeGhError.name === "HttpError") { throw { __is_dust_error: true, message: "Github rate limited", type: "github_rate_limited", }; } - - throw err; } } }