Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Shopify.Webhooks.Registry.process throws error #231

Closed
mkamalkayani opened this issue Aug 15, 2021 · 2 comments
Closed

Shopify.Webhooks.Registry.process throws error #231

mkamalkayani opened this issue Aug 15, 2021 · 2 comments

Comments

@mkamalkayani
Copy link

Issue summary

Sometimes the uninstall webhook route throws an error, and sometimes it works fine. Additionally, the error is misleading, as the uninstall webhook route is getting hit, which means the webhook is registered successfully and it is received by my server.

Failed to process webhook: Error: No webhook is registered for topic app/uninstalled

Expected behavior

The uninstall webhook should be processed consistently.

Actual behavior

Inconsistant behavior by the Shopify.Webhooks.Registry.process(ctx.req, ctx.res)

Relavent code

access mode is online.

   const response = await Shopify.Webhooks.Registry.register({
            shop,
            accessToken,
            path: "/webhooks/app_uninstall",
            topic: "APP_UNINSTALLED",
            webhookHandler: async (topic, shop, body) => {
              await sessionStorage.removeShop(shop);
              console.log("app uninstalled", { topic, shop });
            },
          });
router.post("/webhooks/app_uninstall", async (ctx) => {
  try {
    await Shopify.Webhooks.Registry.process(ctx.req, ctx.res);
    console.log(`Webhook processed, returned status code 200`);
  } catch (error) {
    console.log(`Failed to process webhook: ${error}`);
  }
});
@arsnl
Copy link

arsnl commented Aug 18, 2021

Hi @mkamalkayani ! :) This is a known issue due to the current architecture of the library.

The PR #226 is covering this issue and is currently waiting to be approved by the core team.

Until the PR is merged and pushed on NPM (due to the lack of response from the core team, I think it's gonna take a while...), you can try to apply this hack (#205 (comment)).

@mkevinosullivan
Copy link
Contributor

Closing as webhook handling has changed as of version 2 of the library.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants