Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/server/schemas/sharedApiSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export const contractParamSchema = Type.Object({
export const requestQuerystringSchema = Type.Object({
simulateTx: Type.Optional(
Type.Boolean({
description: "Simulate the transaction without executing it.",
description:
"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.",
default: false,
}),
),
Expand Down
16 changes: 11 additions & 5 deletions src/worker/tasks/sendWebhookWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
type TransactionSchema,
} from "../../server/schemas/transaction";
import { toTransactionReceiptSchema } from "../../server/schemas/transactionReceipt";
import { logger } from "../../utils/logger";
import { redis } from "../../utils/redis/redis";
import { sendWebhookRequest, type WebhookResponse } from "../../utils/webhook";
import { logWorkerExceptions } from "../queues/queues";
import { SendWebhookQueue, type WebhookJob } from "../queues/sendWebhookQueue";

const handler: Processor<any, void, string> = async (job: Job<string>) => {
Expand Down Expand Up @@ -68,19 +68,25 @@ const handler: Processor<any, void, string> = async (job: Job<string>) => {
}
}

// Throw on 5xx so it remains in the queue to retry later.
if (resp && resp.status >= 500) {
// Throw on 5xx so it remains in the queue to retry later.
throw new Error(
const error = new Error(
`Received status ${resp.status} from webhook ${webhook.url}.`,
);
job.log(error.message);
logger({
level: "debug",
message: error.message,
service: "worker",
});
throw error;
}
};

// Must be explicitly called for the worker to run on this host.
export const initSendWebhookWorker = () => {
const _worker = new Worker(SendWebhookQueue.q.name, handler, {
new Worker(SendWebhookQueue.q.name, handler, {
concurrency: 10,
connection: redis,
});
logWorkerExceptions(_worker);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes line that dumps all failing webhooks to log

};
Loading