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

[shopify-app-remix] Cannot read properties of undefined (reading 'headers') #681

Closed
koaqiu opened this issue Mar 1, 2024 · 6 comments
Closed

Comments

@koaqiu
Copy link

koaqiu commented Mar 1, 2024

Issue summary

  • "@shopify/app": "3.56.3",
    "@shopify/cli": "3.56.3",
    "@shopify/polaris": "^12.0.0",
    "@shopify/shopify-api": "^9.2.0",
    "@shopify/shopify-app-remix": "^2.5.0",
    "@shopify/shopify-app-session-storage-prisma": "^4.0.1",
  • Node version:v20.11.0
  • Operating system: windows11

In this tutorial: https://shopify.dev/docs/apps/getting-started/build-qr-code-app?framework=remix

my code

async function supplementQRCode(qrCode:any, graphql:GraphQLClient<any>){
    const qrCodeImagePromise = getQRCodeImage(qrCode.id);

    console.log('qrCode',qrCode);// here can print data
    const response = await graphql(
      `
        query supplementQRCode($id: ID!) {
          product(id: $id) {
            title
            images(first: 1) {
              nodes {
                altText
                url
              }
            }
          }
        }
      `,
      {
        variables: {
          id: qrCode.productId,
        },
      }
    );

  const {
    data: { product },
  } = await response.json();
  return {
    ...qrCode,
    productDeleted: !product?.title,
    productTitle: product?.title,
    productImage: product?.images?.nodes[0]?.url,
    productAlt: product?.images?.nodes[0]?.altText,
    destinationUrl: getDestinationUrl(qrCode),
    image: await qrCodeImagePromise,
  };
}

get error
image

03:29:37 │ remix      │ TypeError: Cannot read properties of undefined (reading 'headers')
03:29:37 │ remix      │     at throwFailedRequest (D:\Works\tmp\diy-goods\node_modules\.pnpm\@[email protected]\
node_modules\@shopify\shopify-api\lib\clients\common.js:52:98)
03:29:37 │ remix      │     at NewGraphqlClient.<anonymous> (D:\Works\tmp\diy-goods\node_modules\.pnpm\@shopify+shopify-
[email protected]\node_modules\@shopify\shopify-api\lib\clients\admin\graphql\client.js:70:49)
03:29:37 │ remix      │     at Generator.next (<anonymous>)
03:29:37 │ remix      │     at fulfilled
(D:\Works\tmp\diy-goods\node_modules\.pnpm\[email protected]\node_modules\tslib\tslib.js:166:62)
03:29:37 │ remix      │     at processTicksAndRejections (node:internal/process/task_queues:95:5)
03:29:37 │ remix      │     at runNextTicks (node:internal/process/task_queues:64:3)
03:29:37 │ remix      │     at process.processImmediate (node:internal/timers:449:9)
03:29:37 │ remix      │ TypeError: Cannot read properties of undefined (reading 'headers')
03:29:37 │ remix      │     at throwFailedRequest (D:\Works\tmp\diy-goods\node_modules\.pnpm\@[email protected]\
node_modules\@shopify\shopify-api\lib\clients\common.js:52:98)
03:29:37 │ remix      │     at NewGraphqlClient.<anonymous> (D:\Works\tmp\diy-goods\node_modules\.pnpm\@shopify+shopify-
[email protected]\node_modules\@shopify\shopify-api\lib\clients\admin\graphql\client.js:70:49)
03:29:37 │ remix      │     at Generator.next (<anonymous>)
03:29:37 │ remix      │     at fulfilled
(D:\Works\tmp\diy-goods\node_modules\.pnpm\[email protected]\node_modules\tslib\tslib.js:166:62)
03:29:37 │ remix      │     at processTicksAndRejections (node:internal/process/task_queues:95:5)
03:29:37 │ remix      │     at runNextTicks (node:internal/process/task_queues:64:3)
03:29:37 │ remix      │     at process.processImmediate (node:internal/timers:449:9)
03:29:37 │ remix      │ TypeError: Cannot read properties of undefined (reading 'headers')
03:29:37 │ remix      │     at throwFailedRequest (D:\Works\tmp\diy-goods\node_modules\.pnpm\@[email protected]\
node_modules\@shopify\shopify-api\lib\clients\common.js:52:98)
03:29:37 │ remix      │     at NewGraphqlClient.<anonymous> (D:\Works\tmp\diy-goods\node_modules\.pnpm\@shopify+shopify-
[email protected]\node_modules\@shopify\shopify-api\lib\clients\admin\graphql\client.js:70:49)
03:29:37 │ remix      │     at Generator.next (<anonymous>)
03:29:37 │ remix      │     at fulfilled
(D:\Works\tmp\diy-goods\node_modules\.pnpm\[email protected]\node_modules\tslib\tslib.js:166:62)
03:29:37 │ remix      │     at processTicksAndRejections (node:internal/process/task_queues:95:5)
03:29:37 │ remix      │     at runNextTicks (node:internal/process/task_queues:64:3)
03:29:37 │ remix      │     at process.processImmediate (node:internal/timers:449:9)
03:29:37 │ remix      │ TypeError: Cannot read properties of undefined (reading 'headers')
03:29:37 │ remix      │     at throwFailedRequest (D:\Works\tmp\diy-goods\node_modules\.pnpm\@[email protected]\
node_modules\@shopify\shopify-api\lib\clients\common.js:52:98)
03:29:37 │ remix      │     at NewGraphqlClient.<anonymous> (D:\Works\tmp\diy-goods\node_modules\.pnpm\@shopify+shopify-
[email protected]\node_modules\@shopify\shopify-api\lib\clients\admin\graphql\client.js:70:49)
03:29:37 │ remix      │     at Generator.next (<anonymous>)
03:29:37 │ remix      │     at fulfilled
(D:\Works\tmp\diy-goods\node_modules\.pnpm\[email protected]\node_modules\tslib\tslib.js:166:62)
03:29:37 │ remix      │     at processTicksAndRejections (node:internal/process/task_queues:95:5)
03:29:37 │ remix      │     at runNextTicks (node:internal/process/task_queues:64:3)
03:29:37 │ remix      │     at process.processImmediate (node:internal/timers:449:9)
@paulomarg
Copy link
Contributor

Hi, thanks for raising this. It seems like there's a bug in the code where we're assuming there will be a response when there is an error, but in this case there isn't one - the real error is masked by this bug, but I'm guessing the request is being aborted somehow.

We'll look into the bug and fix it, but in the meantime I'd suggest checking if the query itself works if you run it in the GraphiQL app from the CLI.

@jahilldev
Copy link

I too have recently started to see this. The GraphQL query is working fine 99% of the time, but every now and then, we'll see this error in our logs.

@paulomarg
Copy link
Contributor

paulomarg commented Apr 8, 2024

I believe this will be fixed by Shopify/shopify-api-js#1330. I'll close this issue but please let us know if it still fails after the next release!

@mkromann
Copy link

I was also getting this error but updated to the latest version today. The nature of the error seem to have changed:
2024 04 10_12 33 44 • iTerm — npm run dev-tunnel@2x

Instead getting this message: [shopify-app/DEBUG] Got a response error from the API: Http request error, no response available.

It's hard to replicate the issue, and I am not sure what triggers it.

@paulomarg
Copy link
Contributor

The previous error reported here was actually masking a different issue - the original request got aborted, but we failed to handle that case properly when trying to log this. This error should now be easier to interpret (not really the case here), or at least catchable so you can dig into the data.

With 16f52ee, which is coming in the next release, we'll also include some more info in that error message, which will hopefully help us identify the root cause of this issue.

@anasdevv
Copy link

@mkromann Were you able to determine what might have been causing the error: Http request error, no response available?
I'm getting this same error on graphql client Error: Http request error, no response available: GraphQL Client: request

It’s tricky to replicate the problem on my end, so any insights you have would be really helpful

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