Skip to content

Commit

Permalink
feat(locksmit): better handling of notification errors
Browse files Browse the repository at this point in the history
  • Loading branch information
julien51 committed Apr 26, 2024
1 parent dacc76e commit 7b2a666
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion locksmith/src/controllers/v2/ticketsController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class TicketsController {

if (event?.data.notifyCheckInUrls) {
for (const url of event.data.notifyCheckInUrls) {
await notify({
const response = await notify({
hookCallback: url,
body: {
owner: tokenOwner,
Expand All @@ -129,6 +129,13 @@ export class TicketsController {
},
},
})
if (response.status !== 200) {
logger.info(
`Received unxpected response when notifying ${url}: ${
response.status
} ${await response.text()}`
)
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions locksmith/src/worker/helpers/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ export async function notify({
method: 'POST',
body: content,
signal: ac.signal,
}).catch((error) => {
logger.error('Error in notify function: ', error)
return {
ok: false,
statusText: 'client error',
status: '400',
text: () => error.message,
json: () => Promise.resolve({ message: error.message }),
}
})

clearTimeout(abortTimeout)
Expand Down

0 comments on commit 7b2a666

Please sign in to comment.