Skip to content

Commit f07ce5c

Browse files
authored
chore: log error in handlePayloadTooBigError (NangoHQ#2576)
I noticed the following error this morning when a runner send the output of a task back to jobs: Error: PUT /tasks/:taskId: status=500, response={"error":{"code":"server_error","message":"Cannot read properties of undefined (reading 'code')"}} It looks like setting the task as failed/succeed fails but the error doesn't have the shape we expect. Adding a try/catch to log the error and let the execution continue and log the setSucceed/setFailed error ## Issue ticket number and link ## Checklist before requesting a review (skip if just adding/editing APIs & templates) - [ ] I added tests, otherwise the reason is: - [ ] I added observability, otherwise the reason is: - [ ] I added analytics, otherwise the reason is:
1 parent 4071ce8 commit f07ce5c

File tree

1 file changed

+14
-10
lines changed
  • packages/jobs/lib/execution/operations

1 file changed

+14
-10
lines changed

packages/jobs/lib/execution/operations/output.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,20 @@ export async function handleError({
7575
}
7676

7777
async function handlePayloadTooBigError({ taskId, error, nangoProps }: { taskId: string; error: ClientError; nangoProps: NangoProps }): Promise<void> {
78-
if (
79-
error.payload &&
80-
typeof error.payload === 'object' &&
81-
'response' in error.payload &&
82-
error.payload['response'] &&
83-
typeof error.payload['response'] === 'object'
84-
) {
85-
const res = error.payload['response'] as unknown as ApiError<string>;
86-
if (res.error.code === 'payload_too_big') {
87-
await orchestratorClient.failed({ taskId, error: new NangoError('script_output_too_big', { syncId: nangoProps.syncId }) });
78+
try {
79+
if (
80+
error.payload &&
81+
typeof error.payload === 'object' &&
82+
'response' in error.payload &&
83+
error.payload['response'] &&
84+
typeof error.payload['response'] === 'object'
85+
) {
86+
const res = error.payload['response'] as unknown as ApiError<string>;
87+
if (res.error.code === 'payload_too_big') {
88+
await orchestratorClient.failed({ taskId, error: new NangoError('script_output_too_big', { syncId: nangoProps.syncId }) });
89+
}
8890
}
91+
} catch (err: unknown) {
92+
logger.error(`failed to handle payload too big error for task ${taskId}`, err);
8993
}
9094
}

0 commit comments

Comments
 (0)