Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
Hi,
been struggling with this for a few days.
I have an uninstall webhook, but it gets fired repeatedly. I'm using koa-shopify-webhooks package and I have the following code:
receiveWebhook({ path: '/webhooks/uninstall', secret: [SHOPIFY-SECRET], // called when a valid webhook is received onReceived(ctx) { ctx.response.status = 200 ctx.response.body = 'success' ctx.res.status = 200 ctx.res.body = 'success' ctx.status = 200 ctx.body = 'success' console.log('received webhook: ', ctx.state.webhook.topic,ctx.state.webhook.domain); }, }),
As you can see I've tried multiple ways of setting the status and body of the response (all pulled from different documentation sources), however the repeated hooks persist.
I have previously console logged each before and after to ensure they were set correctly.
I am using an ngrok address currently for testing - just in case this is relevant.
Looking at the ngrok logs it looks like it's still not returning the 200
Thanks for any insight from koa veterans!
Hey @reecewilliams,
Duplicate webhooks usually occur when your app takes too long (> 5s) to respond to Shopify, so it's assumed the delivery failed and Shopify retries. If you can provide the X-Request-ID from the request headers of a webhook that's fired more than once, I can check our logs to confirm.
JB | Solutions Engineer @ Shopify
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Do webhook requests contain an `X-Request-ID` header? I don't it listed in the documentation, or when inspected locally.
https://shopify.dev/docs/admin-api/rest/reference/events/webhook?api[version]=2020-04
Hi @_JB
I can't see an X-Request-ID on any of the webhook headers. Will this be anywhere else in the request?
Thanks,
Reece
Hey @reecewilliams @traderkrut ,
My apologies, looks like webhooks don't contain that header. If you can provide the resource id and an approximate timeframe from when you saw the duplicate, I can use that to find the result in our logs.
JB | Solutions Engineer @ Shopify
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Thanks for looking into this @_JB
The id passed was
28881158218
There were several re-attempts around 3 hours ago.
Just to confirm, the koa package is returning with a 302 status code. My assumption is that this is throwing it off. Is this not the case?