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

Webhooks are not being registered #1940

Closed
5 tasks done
jagthedrummer opened this issue Feb 14, 2025 · 10 comments
Closed
5 tasks done

Webhooks are not being registered #1940

jagthedrummer opened this issue Feb 14, 2025 · 10 comments

Comments

@jagthedrummer
Copy link

Issue summary

Before opening this issue, I have:

  • Upgraded to the latest version of the package
    • shopify_app version: 22.5.1
    • Ruby version: 3.4.1
    • Operating system: MacOS & Linux
  • Set log_level: :debug in my configuration, if applicable
  • Found a reliable way to reproduce the problem that indicates it's a problem with the package
  • Looked for similar issues in this repository
  • Checked that this isn't an issue with a Shopify API

Webhooks that I've configured in config/initializers/shopify_app.rb are not being registered.

I have a block like this:

  config.webhooks = [
    {topic: 'app/uninstalled', address: "#{ENV['SHOPIFY_APP_BASE']}/webhooks/app_uninstalled", format: 'json'},
    {topic: 'customers/data_request', address: "#{ENV['SHOPIFY_APP_BASE']}/webhooks/customers_data_request", format: 'json'},
    {topic: 'customers/redact', address: "#{ENV['SHOPIFY_APP_BASE']}/webhooks/customers_redact", format: 'json'},
    {topic: 'orders/create', address: "#{ENV['SHOPIFY_APP_BASE']}/webhooks/orders_create", format: 'json'},
    {topic: 'shop/redact', address: "#{ENV['SHOPIFY_APP_BASE']}/webhooks/shop_redact", format: 'json'},
    {topic: 'shop/update', address: "#{ENV['SHOPIFY_APP_BASE']}/webhooks/shop_updated", format: 'json'},
    {topic: 'themes/update', address: "#{ENV['SHOPIFY_APP_BASE']}/webhooks/theme_updated", format: 'json'}
  ]

But none of those webhooks are registered when a new shop installs.

Expected behavior

The webhooks should be registered.

Actual behavior

The webhooks are not registered.

Steps to reproduce the problem

  1. Configure some webhooks in config.webhooks
  2. Install the app in a shop
  3. Notice that webhooks are not registered
@uurcank
Copy link
Contributor

uurcank commented Feb 15, 2025

I think it has all moved to shopify.toml file with shopify managed scopes.

@jagthedrummer
Copy link
Author

@uurcank I'm not finding anything in the changelog saying that webhooks won't be registered anymore, and the docs still describe using them: https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/webhooks.md#manage-shop-specific-webhooks-using-shopifyappwebhooksmanager

@remy727
Copy link
Contributor

remy727 commented Feb 18, 2025

How did you add the webhook?
Did you add the webhook using add_webhook generator?

rails g shopify_app:add_webhook --topic carts/update --path webhooks/carts_update

@jagthedrummer
Copy link
Author

@remy727 I honestly don't remember how I added them. This is in an app that I've been running for a while and I just noticed that somewhere along the way it stopped registering webhooks. If I manually register the webhooks they work as expected, so it's not a problem with file paths or namespaces or any of the other magic bits that this gem provides. It's just that the automatic registration from the config isn't happening.

@lizkenyon
Copy link
Contributor

Hi 👋

I was not able to reproduce this on my side using the Shopify App Template Ruby, and setting up API webhooks in the config object. My webhook subscription was successfully created.

It may be helpful for debugging to take a look at this commit, it is showing the code required in the shopify_app.rb for setting up the webhooks.

It may also be helpful to review the logs from your app after install.
You should see the webhooks job being called after token exchange.

14:33:00 │               web-backend │   Shop Load (0.1ms)  SELECT "shops".* FROM "shops" WHERE "shops"."shopify_domain" = ? LIMIT ?  [["shopify_domain", ".myshopify.com"],
["LIMIT", 1]]
14:33:00 │               web-backend │ [ ShopifyApp | INFO | Shop Not Found ] Performing Token Exchange for [.myshopify.com] - (Offline)
14:33:01 │               web-backend │   CACHE Shop Load (0.0ms)  SELECT "shops".* FROM "shops" WHERE "shops"."shopify_domain" = ? LIMIT ?  [["shopify_domain", ".myshopify.com"],
["LIMIT", 1]]
14:33:01 │               web-backend │   TRANSACTION (0.1ms)  begin transaction
14:33:01 │               web-backend │   Shop Exists? (21.7ms)  SELECT 1 AS one FROM "shops" WHERE LOWER("shops"."shopify_domain") = LOWER(?) LIMIT ?  [["shopify_domain",
"i.myshopify.com"], ["LIMIT", 1]]
14:33:01 │               web-backend │   Shop Create (1.2ms)  INSERT INTO "shops" ("shopify_domain", "shopify_token", "created_at", "updated_at", "access_scopes") VALUES (?, ?, ?, ?, ?) RETURNING "id"
[["shopify_domain", ".myshopify.com"], ["shopify_token", "[FILTERED]"], ["created_at", "2025-02-18 20:33:01.202588"], ["updated_at", "2025-02-18 20:33:01.202588"],
["access_scopes", "write_products"]]
14:33:01 │               web-backend │   TRANSACTION (0.4ms)  commit transaction
14:33:01 │               web-backend │ [ActiveJob] Enqueued ShopifyApp::WebhooksManagerJob (Job ID: 59461a7c-9c9a-415f-9e1e-9ccc6e01a285) to Async(default)
14:33:01 │               web-backend │   Shop Load (0.1ms)  SELECT "shops".* FROM "shops" WHERE "shops"."shopify_domain" = ? LIMIT ?  [["shopify_domain", ".myshopify.com"],
["LIMIT", 1]]
14:33:01 │               web-backend │   Rendering text template
14:33:01 │               web-backend │   Rendered text template (Duration: 0.0ms | Allocations: 4)
14:33:01 │               web-backend │ Completed 200 OK in 616ms (Views: 3.2ms | ActiveRecord: 25.4ms | Allocations: 110749)
14:33:01 │               web-backend │
14:33:01 │               web-backend │
14:33:01 │               web-backend │ [ActiveJob] [ShopifyApp::WebhooksManagerJob] [59461a7c-9c9a-415f-9e1e-9ccc6e01a285] Performing ShopifyApp::WebhooksManagerJob (Job ID: 59461a7c-9c9a-415f-9e1e-9ccc6e01a285)
from Async(default) enqueued at 2025-02-18T20:33:01.207717000Z
14:33:02 │               web-backend │ [ActiveJob] [ShopifyApp::WebhooksManagerJob] [59461a7c-9c9a-415f-9e1e-9ccc6e01a285] Performed ShopifyApp::WebhooksManagerJob (Job ID: 59461a7c-9c9a-415f-9e1e-9ccc6e01a285)
from Async(default) in 1008.84ms

@lizkenyon lizkenyon added the Waiting for Response Need more information before we can provide more assistance label Feb 18, 2025
Copy link

We are closing this issue because we did not hear back regarding additional details we needed to resolve this issue. If the issue persists and you are able to provide the missing clarification we need, feel free to respond and reopen this issue.

We appreciate your understanding as we try to manage our number of open issues.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2025
@jagthedrummer
Copy link
Author

It turns out that this was related to having to deal with the premature removal of the ScriptTagsManager (#1891). The recommendation of implementing custom_post_authenticate_tasks did not mention that doing so would stop the automatic registering of webhooks. It continues to feel hostile that you all are removing code for features that are not even officially deprecated.

And the bot auto-closing issues after only one week feels even more hostile. Please disable that thing.

@github-actions github-actions bot removed the Waiting for Response Need more information before we can provide more assistance label Mar 6, 2025
@jagthedrummer
Copy link
Author

Also, the bot says this:

feel free to respond and reopen this issue.

But reopening auto-closed issues doesn't seem to be allowed.

@vjnunez
Copy link

vjnunez commented Mar 7, 2025

Hey @jagthedrummer, im having the same issue with webhooks not auto registering in the shop. How did you solve this? I just created a new app using shopify_app gem.

@jagthedrummer
Copy link
Author

@vjnunez I ended up writing custom code to register the webhooks manually and added it to the class that I registered as custom_post_authenticate_tasks.

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

No branches or pull requests

5 participants