Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): Enrich webhook errors #3319

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

nalanj
Copy link
Contributor

@nalanj nalanj commented Jan 16, 2025

Enriches webhook errors with much more information about the request that was made, to help customers with debugging.

Of course they should log these requests themselves, but there are certainly also cases like gateway errors where they wouldn't receive these and it could be good to see the full request from our side:

image

In that screenshot above, I fixed this small bug:
image

How I tested it:

  • Set up webhooks to whatever test endpoint you like to use, but make sure they fail
  • Run a sync so it delivers webhooks
  • Check out the logs for failed webhook requests

@nalanj nalanj self-assigned this Jan 16, 2025
@nalanj nalanj marked this pull request as ready for review January 16, 2025 15:16
@nalanj nalanj requested a review from a team January 16, 2025 15:16
packages/webhooks/tsconfig.json Outdated Show resolved Hide resolved
packages/webhooks/lib/utils.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@bodinsamuel bodinsamuel left a comment

Choose a reason for hiding this comment

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

Same points already raised by Thomas, otherwise looks good 👍🏻

Can you take the opportunity to log success and error the same way in deliver()?

@nalanj nalanj marked this pull request as draft January 16, 2025 16:33
@nalanj nalanj marked this pull request as ready for review January 16, 2025 18:46
@nalanj nalanj requested review from bodinsamuel and TBonnin January 16, 2025 18:46
@nalanj
Copy link
Contributor Author

nalanj commented Jan 16, 2025

@bodinsamuel handled deliver errors in a36990b

Copy link
Collaborator

@bodinsamuel bodinsamuel left a comment

Choose a reason for hiding this comment

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

💪🏻

if (response.status >= 200 && response.status < 300) {
await logCtx.info(
await logCtx.http(
`${webhookType} webhook sent successfully to the ${type} ${url} and received with a ${response.status} response code${endingMessage ? ` ${endingMessage}` : ''}.`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

message for HTTP log should be METHOD URL (yes it's not good everywhere :D)

@@ -134,6 +134,7 @@ export interface MessageRow {
response: {
code: number;
headers: Record<string, string>;
body?: unknown;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just had a thought before going to bed, you need to add this prop to schema.ts as keyword "index": false and "doc_values": false otherwise it will blow up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2c9e4f9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants