Skip to content

Commit

Permalink
fix: silence GH rate limiting (#2596)
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanierh authored Nov 17, 2023
1 parent edceae6 commit 7b8683f
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions connectors/src/connectors/github/temporal/cast_known_errors.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { RequestError } from "@octokit/types";
import {
ActivityExecuteInput,
ActivityInboundCallsInterceptor,
Next,
} from "@temporalio/worker";

export class GithubCastKnownErrorsInterceptor
implements ActivityInboundCallsInterceptor
{
Expand All @@ -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;
}
}
}

0 comments on commit 7b8683f

Please sign in to comment.