From b8fdd7e9017bbb53b991503766cebf58a771fb58 Mon Sep 17 00:00:00 2001 From: Shine Li Date: Thu, 6 Jun 2024 18:00:53 +1000 Subject: [PATCH] fix: webhook event parsing bug (#1874) --- packages/webhook/sdk/src/handler.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/webhook/sdk/src/handler.ts b/packages/webhook/sdk/src/handler.ts index 992f7ddebf..508277f305 100644 --- a/packages/webhook/sdk/src/handler.ts +++ b/packages/webhook/sdk/src/handler.ts @@ -72,8 +72,9 @@ export const handle = async ( }); }); - const event = JSON.parse(msg.Message); if (msg.Type === 'Notification') { + // the msg.Message is only a valid JSON string when the message is of Type Notification + const event = JSON.parse(msg.Message); switch (event.event_name) { case 'imtbl_zkevm_mint_request_updated': if (handlers?.zkevmMintRequestUpdated) { @@ -176,7 +177,8 @@ export const handle = async ( if (handlers?.all) { await handlers?.all(event); } + return event; } - return event; + return null; };