Problem with Subscription Webhook for Staff user: Node + React Tutorial

New Member
1 0 0

Hi all,

My partner and I have been trying to develop an app following the official Node and React tutorial.


I've finished the tutorial.
Recently, I've given staff access to my partner to my development store so he could take a look at the result of the tutorial.

[Problem Description]
The app fails when my partner tries to access it.
Steps taken: My partner goes on the admin dashboard of the store, goes into Apps.
Selects the app we've created ("My First App - Tutorial"), but the app then shows an Internal Server Error (because of the exception below that we don't catch).

The relevant server logs make mention of:
Failed to register webhook {
2020-09-20T12:25:11.721015+00:00 app[web.1]: data: {
2020-09-20T12:25:11.721016+00:00 app[web.1]: webhookSubscriptionCreate: { userErrors: [Array], webhookSubscription: null }
2020-09-20T12:25:11.721016+00:00 app[web.1]: },
2020-09-20T12:25:11.721016+00:00 app[web.1]: extensions: {
2020-09-20T12:25:11.721017+00:00 app[web.1]: cost: {
2020-09-20T12:25:11.721018+00:00 app[web.1]: requestedQueryCost: 10,
2020-09-20T12:25:11.721018+00:00 app[web.1]: actualQueryCost: 10,
2020-09-20T12:25:11.721019+00:00 app[web.1]: throttleStatus: [Object]
2020-09-20T12:25:11.721021+00:00 app[web.1]: }
2020-09-20T12:25:11.721022+00:00 app[web.1]: }
2020-09-20T12:25:11.721022+00:00 app[web.1]: }
2020-09-20T12:25:12.082702+00:00: at=info method=GET path="/auth/callback?code=<some code>&hmac=<some hmac>&shop=<my shop url>&state=<some state>&timestamp=1600604710" host=<the host> request_id=dd2ada4a-c7d3-41af-9087-0918cc679dea fwd=<some IP> dyno=web.1 connect=1ms service=1297ms status=500 bytes=176 protocol=https
2020-09-20T12:25:12.080883+00:00 app[web.1]:
2020-09-20T12:25:12.080893+00:00 app[web.1]: TypeError: Cannot read property 'appSubscriptionCreate' of undefined
2020-09-20T12:25:12.080894+00:00 app[web.1]: at getSubscriptionUrl (/app/server/getSubscriptionUrl.js:48:47)
2020-09-20T12:25:12.080896+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-09-20T12:25:12.080897+00:00 app[web.1]: at async afterAuth (/app/server.js:59:17)

From what we understand, this happens because the subscription webhook cannot be created successfully.

[What we tried]
When I login on my browser, or on his, everything works fine.
If I uninstall the app, only I can re-install it.

If he tries authenticating using this URL: https://<our host>/auth?shop=our_shop_url, he gets the same error as listed above.
For me though (the store owner), everything works fine, whether I try to access the app through the Shopify admin or through this URL.

The same error shows up whether he is a Collaborator of the store or a Staff member.
(With full access).

We tried using the app with another collaborator, with the same issue.

[Probable Cause]
From the documentation I can read:
"The staff member can install apps as long as their store permissions match the permissions that the app requires. For example, if an app needs access to orders, then the staff member needs the Orders permission to install the app. Only the store owner can approve app charges."

The webhook that fails is the one that sets up the subscription. 
But it fails, even when the app is already installed.


I have the following questions, if anyone can help shed some light on this:

  1. In the tutorial, every time someone new tries to use the app, the app tries to setup the webhook.
    Is this something that we need to keep for our app?
    This runs even when the app has already been installed.
  2. Is there a way to run this logic that sets up the webhook only when needed?
    So that it doesn't run when the app is already installed?
  3. How do we get more details on the source of the error above?
    A way to know for sure what the cause is.