Skip to content

Commit 8cbd4dc

Browse files
committed
fix(webapp): reduce error-level log noise for handled/benign cases
Two changes to cut Sentry volume from logs that represent handled conditions, not real errors (combined ~1600/hr in prod): 1. api.v1.waitpoints.tokens.$waitpointFriendlyId.complete.ts The route throws `json(..., { status: 404 })` when a waitpoint isn't found, but the generic catch block caught that Response, logged it as an error (with an empty {} body because Error fields are non-enumerable), and rethrew as a 500 — so clients saw a 500 instead of the intended 404, and every stale-waitpoint request produced a Sentry event. Fix: re-throw Response objects unchanged so the correct status propagates and we don't log user 404s as errors. Also serialize remaining Error instances explicitly (name/message/stack) so the logs are actionable when we do hit a real error. 2. v3/marqs/sharedQueueConsumer.server.ts:603 "Task run has invalid status for execution. Going to ack" — the message itself says we're handling it gracefully. Benign race between dequeue and completion/cancellation. Demote to warn.
1 parent ff290df commit 8cbd4dc

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

apps/webapp/app/routes/api.v1.waitpoints.tokens.$waitpointFriendlyId.complete.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,16 @@ const { action, loader } = createActionApiRoute(
7272
{ status: 200 }
7373
);
7474
} catch (error) {
75-
logger.error("Failed to complete waitpoint token", { error });
75+
// Re-throw Response objects (intentional HTTP responses like the 404 above) so the
76+
// client gets the correct status code instead of a 500, and we don't log them as errors.
77+
if (error instanceof Response) throw error;
78+
79+
logger.error("Failed to complete waitpoint token", {
80+
error:
81+
error instanceof Error
82+
? { name: error.name, message: error.message, stack: error.stack }
83+
: error,
84+
});
7685
throw json({ error: "Failed to complete waitpoint token" }, { status: 500 });
7786
}
7887
}

apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ export class SharedQueueConsumer {
600600
(!retryingFromCheckpoint &&
601601
!EXECUTABLE_RUN_STATUSES.withoutCheckpoint.includes(existingTaskRun.status))
602602
) {
603-
logger.error("Task run has invalid status for execution. Going to ack", {
603+
logger.warn("Task run has invalid status for execution. Going to ack", {
604604
queueMessage: message.data,
605605
messageId: message.messageId,
606606
taskRun: existingTaskRun.id,

0 commit comments

Comments
 (0)