Skip to content

Commit b5582d9

Browse files
authored
chore: move webhook errors to debug logging (#758)
1 parent b5f54bf commit b5582d9

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/server/schemas/sharedApiSchemas.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export const contractParamSchema = Type.Object({
2828
export const requestQuerystringSchema = Type.Object({
2929
simulateTx: Type.Optional(
3030
Type.Boolean({
31-
description: "Simulate the transaction without executing it.",
31+
description:
32+
"Simulates the transaction before adding it to the queue, returning an error if it fails simulation. Note: This step is less performant and recommended only for debugging purposes.",
3233
default: false,
3334
}),
3435
),

src/worker/tasks/sendWebhookWorker.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {
1212
type TransactionSchema,
1313
} from "../../server/schemas/transaction";
1414
import { toTransactionReceiptSchema } from "../../server/schemas/transactionReceipt";
15+
import { logger } from "../../utils/logger";
1516
import { redis } from "../../utils/redis/redis";
1617
import { sendWebhookRequest, type WebhookResponse } from "../../utils/webhook";
17-
import { logWorkerExceptions } from "../queues/queues";
1818
import { SendWebhookQueue, type WebhookJob } from "../queues/sendWebhookQueue";
1919

2020
const handler: Processor<any, void, string> = async (job: Job<string>) => {
@@ -68,19 +68,25 @@ const handler: Processor<any, void, string> = async (job: Job<string>) => {
6868
}
6969
}
7070

71+
// Throw on 5xx so it remains in the queue to retry later.
7172
if (resp && resp.status >= 500) {
72-
// Throw on 5xx so it remains in the queue to retry later.
73-
throw new Error(
73+
const error = new Error(
7474
`Received status ${resp.status} from webhook ${webhook.url}.`,
7575
);
76+
job.log(error.message);
77+
logger({
78+
level: "debug",
79+
message: error.message,
80+
service: "worker",
81+
});
82+
throw error;
7683
}
7784
};
7885

7986
// Must be explicitly called for the worker to run on this host.
8087
export const initSendWebhookWorker = () => {
81-
const _worker = new Worker(SendWebhookQueue.q.name, handler, {
88+
new Worker(SendWebhookQueue.q.name, handler, {
8289
concurrency: 10,
8390
connection: redis,
8491
});
85-
logWorkerExceptions(_worker);
8692
};

0 commit comments

Comments
 (0)