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

[Bug]: Post purchase extensions not working #355

Closed
2 tasks done
RapGeneral opened this issue Aug 24, 2022 · 15 comments · Fixed by #371 or #401
Closed
2 tasks done

[Bug]: Post purchase extensions not working #355

RapGeneral opened this issue Aug 24, 2022 · 15 comments · Fixed by #371 or #401
Assignees
Labels
Type: Bug Something isn't working

Comments

@RapGeneral
Copy link

RapGeneral commented Aug 24, 2022

Please confirm that you have:

  • Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
  • Reproduced the issue in the latest CLI version.

In which of these areas are you experiencing a problem?

App, Extension

Expected behavior

After I run yarn scaffold extension and go trough all the steps, I expect when I run yarn dev and configure the chrome extension to view my post purchase extension.

Actual behavior

For versions prior to 3.8.0 I do not see my extension.
What I notice is that upon arriving at the Shipping page, just before I complete my order, a call is made to the tunnel.
The request loads fine, however this error is thrown in the console:
Refused to execute script from 'https://a88e-95-43-129-67.eu.ngrok.io/extensions/dev-c97057cd-ea1e-4a36-bb8f-254b0efe2ea3/assets/main.js' because its MIME type ('text/plain') is not executable.
I tried setting an application/javascript header, but this changed nothing.

Version 3.8.0 just throws an error at yarn dev:

Stack trace

3.8.0 Problem:
extensions | basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
extensions |           ^^^^^^^
extensions |
extensions | SyntaxError: missing ) after argument list
extensions |     at Object.compileFunction (node:vm:352:18)
extensions |     at wrapSafe (node:internal/modules/cjs/loader:1033:15)
extensions |     at Module._compile (node:internal/modules/cjs/loader:1069:27)
extensions |     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
extensions |     at Module.load (node:internal/modules/cjs/loader:981:32)
extensions |     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
extensions |     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
extensions |     at node:internal/main/run_main_module:17:47)

Reproduction steps

For 3.8.0 prior

  1. Scaffold new application by running yarn create @shopify/app. Choose the node template
  2. Scaffold a post-purchase-extension by running yarn scaffold extension
  3. Run yarn dev.
  4. After configuring tunnels, copy the relevant link in the shopify chrome post purchase extension
  5. Try creating a new order at a test store
  6. At the Shipping observe the error in the console.

For 3.8.0:

  1. Scaffold new application by running yarn create @shopify/app. Choose the node template
  2. Scaffold a post-purchase-extension by running yarn scaffold extension
  3. Run yarn dev.
  4. Observe the error in the console.

Operating System

Windows 10

Shopify CLI version (check your project's package.json if you're not sure)

First bug: 3.71. Second bug: 3.8.0

Shell

Powershell and Windows CMD

Node version (run node -v if you're not sure)

16.15.1

What language and version are you using in your application?

Default node template

@RapGeneral RapGeneral added the Type: Bug Something isn't working label Aug 24, 2022
@abeninski
Copy link

I have the exact same issue:

When running the post purchase extension I get this error in the chrome when I try to open post purchase screen or directly visit extension console.

image

@alvaro-shopify
Copy link
Contributor

Hi! Thank you for opening this issue. As you have pointed, it seems there is a problem with current CLI Go library version and widows 10 when resolving the mime type for .js files. It seems to be resolved in this go issue for the 1.19 version.
We are going to investigate if upgrading Go is the correct solution or if we should find out another workaround that does not force the CLI to use the latest version
We will update this issue as soon as we have the final solution.
Sorry for inconveniences.

@RapGeneral
Copy link
Author

RapGeneral commented Aug 26, 2022

Hi! Thank you for opening this issue. As you have pointed, it seems there is a problem with current CLI Go library version and widows 10 when resolving the mime type for .js files. It seems to be resolved in this go issue for the 1.19 version. We are going to investigate if upgrading Go is the correct solution or if we should find out another workaround that does not force the CLI to use the latest version We will update this issue as soon as we have the final solution. Sorry for inconveniences.

Hello! Thanks for the reply.
The interesting part is that on 3.8.0 I am able to open the extensions management console (but the extension build fails).
I suspect it may have already been resolved, but there is no way for me to check this.

@abeninski
Copy link

Hi! Thank you for opening this issue. As you have pointed, it seems there is a problem with current CLI Go library version and widows 10 when resolving the mime type for .js files. It seems to be resolved in this go issue for the 1.19 version. We are going to investigate if upgrading Go is the correct solution or if we should find out another workaround that does not force the CLI to use the latest version We will update this issue as soon as we have the final solution. Sorry for inconveniences.

Are you saying that shopify CLI uses GO lang because I use nodejs environment?

@alfonso-noriega
Copy link
Contributor

Hi @abeninski , regardless the flavour of the template you choose CLI uses a go library to scaffold and serve.
Related to the issue, did you get the error using CLI version 3.8.0 or a prior one?

@alfonso-noriega
Copy link
Contributor

Hi! Thank you for opening this issue. As you have pointed, it seems there is a problem with current CLI Go library version and widows 10 when resolving the mime type for .js files. It seems to be resolved in this go issue for the 1.19 version. We are going to investigate if upgrading Go is the correct solution or if we should find out another workaround that does not force the CLI to use the latest version We will update this issue as soon as we have the final solution. Sorry for inconveniences.

Hello! Thanks for the reply. The interesting part is that on 3.8.0 I am able to open the extensions management console (but the extension build fails). I suspect it may have already been resolved, but there is no way for me to check this.

@RapGeneral, we did not managed yet to reproduce the error mentioned for 3.8.0 so it is still not clear whether this is a different issue or the same. As soon as we get more info we will share the findings.

@abeninski
Copy link

abeninski commented Aug 26, 2022

Hi @abeninski , regardless the flavour of the template you choose CLI uses a go library to scaffold and serve. Related to the issue, did you get the error using CLI version 3.8.0 or a prior one?

Thanks for the reply.
Can I do anything locally as a workaround?

With 3.8.0 after post purchase ui extension scaffold and run yarn dev extension build breaks with this error:
image

I tried with node 16, 17 and 18

@alfonso-noriega
Copy link
Contributor

Hi @abeninski , @RapGeneral. I am sorry to say that we did not managed yet to reproduce the same error on CLI version 3.8.0, but we will keep trying to find out the source of the issue. It will be very helpful if you have a public repository that we can clone and try to reproduce the error.

In the meantime, if this problem is blocking you we suggest you follow the next workaround:

  • Downgrade back to CLI 3.7.x
  • Remove your home/go directory to avoid cached modules (if exists)
  • Install Go 1.19
  • SHOPIFY_ENV=development yarn dev (this will generate a local go binary which is will be used it to serve)

@alfonso-noriega
Copy link
Contributor

@RapGeneral , @abeninski a new release of the CLI (3.9.0) is out and contains the changes to ignore windows registry content type. Could you please check if this version fixes your problem and give us some feedback?

@abeninski
Copy link

Hey @alfonso-noriega thanks for providing the fix but unfortunately still getting the 3.8 error:
image

Do you have any idea what might be causing it. I'm running on Windows 11

@alfonso-noriega
Copy link
Contributor

hey @abeninski , @RapGeneral, we managed to reproduce the error and find the root cause. A new hot fix release will come soon. Basically node is generating in Windows a shell script and cmd files pointing to the node file which needs to be executed. The path of this files are provided to the CLI as entry point but the CLI expects to receive instead the path to a valid node file and fails when executing.
As soon as the new release is out I will ping you here.

@alfonso-noriega
Copy link
Contributor

FYI @abeninski, @RapGeneral, the CLI 3.9.1 is out and should resolve this problem.

@RapGeneral
Copy link
Author

@alfonso-noriega I have tested with 3.9.2.
Both issues are fixed and no longer reproducible.
Thanks for the quick response and great job!

@abeninski
Copy link

Same for me. All issues resolved. Thanks alot!

@alfonso-noriega
Copy link
Contributor

Great news! Thanks a lot for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
4 participants