Skip to content

Commit

Permalink
Handle transient nango and notion errors (#2312)
Browse files Browse the repository at this point in the history
  • Loading branch information
spolu authored Oct 31, 2023
1 parent 37df6dc commit de55002
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export class NotionCastKnownErrorsInterceptor
};
}
} else if (UnknownHTTPResponseError.isUnknownHTTPResponseError(err)) {
if ([502, 504].includes(err.status)) {
// sometimes notion returns 502/504s, they are transient and look
// like rate limiting errors
if ([502, 504, 530].includes(err.status)) {
// Sometimes notion returns 502/504s, they are transient and look like rate limiting
// errors. 530 is transient and looks like DNS errors.
throw {
__is_dust_error: true,
message: err.message,
Expand Down
1 change: 1 addition & 0 deletions connectors/src/lib/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function errorFromAny(e: any): Error {
export type WorkflowErrorType =
| "unhandled_internal_activity_error"
| "transient_upstream_activity_error"
| "transient_nango_activity_error"
| "upstream_is_down_activity_error";

export type WorkflowError = {
Expand Down
11 changes: 9 additions & 2 deletions connectors/src/lib/nango_client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Nango } from "@nangohq/node";
import axios from "axios";

import { ExternalOauthTokenError } from "@connectors/lib/error";
import { ExternalOauthTokenError, WorkflowError } from "@connectors/lib/error";

import { Err, Ok, Result } from "./result";

Expand Down Expand Up @@ -36,8 +36,15 @@ class CustomNango extends Nango {
}
}
}
if (e.status === 520 && e.code === "ERR_BAD_RESPONSE") {
const workflowError: WorkflowError = {
type: "transient_nango_activity_error",
message: `Nango transient 520 errors`,
__is_dust_error: true,
};
throw workflowError;
}
}

throw e;
}
}
Expand Down

0 comments on commit de55002

Please sign in to comment.