gnikyt / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
1.24k stars 374 forks source link

Uninstall and (quick) reinstall sometimes not possible (slow webhook) #577

Closed cbergen closed 4 years ago

cbergen commented 4 years ago

Expected Behavior

As a shop owner (or shopify app reviewer) I should be able to uninstall and directly reinstall the app.

Current Behavior

Often, when trying to reinstall the app, the installation will try to redirect to the embedded app home page. Instead of displaying the home page or the billing page, a 404 message is displayed.

Failure Information

The issue stems from the Shopify webhook not being received soon enough. The user row in the database hasn't yet been deleted because the "app/uninstalled" job hasn't been triggered yet.

Possibly related issues: #90 #529 #548 Possible solution: https://stackoverflow.com/a/14420395/3976381

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Install the app on a test site
  2. Verify that app/uninstalled webhook was registered
  3. Uninstall app
  4. Quickly re-install the app (before the webhook has a chance to fire)

Context

cbergen commented 4 years ago

I realize this has been discussed a few times but I don't think the app/uninstalled webhook solution is good enough. We can't rely on webhooks to trigger quick enough. And being able to uninstall/reinstall quickly is an important function since the app review process specifically requires it.

The solution mentioned at stackoverflow here: https://stackoverflow.com/a/14420395/3976381 seems to be good guidance to a solution.

I have only briefly used this package so I might be looking in the wrong place but perhaps adding a verification that the app is still installed in the AuthShopify middleware would solve the problem with reinstallation. I'm not sure if this is the best timing for the verification. Would the Shopify API get called too often?

There is also the problem with a late uninstall webhook after the app has been reinstalled. If the AppUninstalledJob is run then the store user will get mistakenly soft-deleted. To solve this issue we could do a similar verification in AppUninstalledJob. The soft-deleting should only happen if the app really is uninstalled.

gnikyt commented 4 years ago

There is nothing I can do in this area, Shopify sends the webhook. Anyone is welcome to try work arounds like the one posted in Stack Overflow and have a custom AppUninstalledJob. I don't feel its a good idea to support some sort of workaround internally.

cbergen commented 4 years ago

I wouldn't classify this as a work around. It's an expected behaviour of webhooks that they may not fire immediately. Relying on webhooks for this just seems like the wrong approach.