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

Transient shopify error (for html response instead of json) is thrown as HttpRequestError instead of HttpRetriableError #257

Closed
wszaranski opened this issue Nov 10, 2021 · 4 comments · Fixed by #398

Comments

@wszaranski
Copy link

Issue summary

Sometimes query returns non json response (probably html but only parsing error is logged).
This error is wrongly interpreted as request error and isn't retried.

Expected behavior

HttpRetriableError should be thrown instead of HttpRequestError

Actual behavior

When we get non json response HttpRequestError which is caused by response.json() parsing HttpRequestError is thrown.

Failed to make Shopify HTTP request: FetchError: invalid json response body at https://XXX.myshopify.com/admin/api/2021-07/products.json?limit=250&page_info=XXX reason: Unexpected token < in JSON at position 0

Steps to reproduce the problem

It's hard to provide reproduce steps for transient error but I'll provide PR with this situation handled in test case.

@mllemango
Copy link
Contributor

Hey @wszaranski, thanks for putting in a PR for your issue. I'm going to ask that we hold off on your proposed solution since the problem I want to tackle is why you're seeing intermittent HTML responses in the first place.
What are your thoughts on adding an Accept header instead and seeing if you're still running into this issue?

@wszaranski
Copy link
Author

I have already applied this patch using patch-package but I can still add your suggestion and add logs to check if original error still persists. Sorry I didn't get back to you but time before Black Friday and Christmas isn't the best for this kind of changes.
I'll do my best to make sure this will be tested in January.

@wszaranski
Copy link
Author

wszaranski commented Mar 15, 2022

@mllemango it looks like it could be cloudflare try again response. This are the response headers. I think with date and x-request-id you should be able to track what was happening. Please let me know if you need anything more.

alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
cf-cache-status: DYNAMIC
cf-ray: 6e848b6169e38f29-IAD
connection: close
content-type: text/html
date: Mon, 07 Mar 2022 16:00:31 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
retry-after: 151
server: cloudflare
transfer-encoding: chunked
x-content-type-options: nosniff
x-dc: gcp-us-east1,gcp-us-central1
x-download-options: noopen
x-permitted-cross-domain-policies: none
x-request-id: 2044cbcd-33d0-47b1-861e-f12c942db41b
x-sorting-hat-podid: 188
x-sorting-hat-shopid: 17087943
x-xss-protection: 1; mode=block

@mariusa
Copy link

mariusa commented May 6, 2022

Also getting this intermittently, from admin api:
Failed to make Shopify HTTP request: FetchError: invalid json response body at https://shop.myshopify.com/admin/api/2022-04/graphql.json reason: Unexpected token < in JSON at position 0

without any other detail. Would help to log the actual response, probably it has some detail about the error. Can't reproduce reliably.

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

Successfully merging a pull request may close this issue.

3 participants