hygraph / hygraph-commerce-starter

Home Page:https://commerce.withheadlesscms.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Webhook error in Stripe

nachoaldamav opened this issue · comments

When the payment is completed the webhook function retrieves an error

A server error has occurred
FUNCTION_INVOCATION_FAILED

i've tried a fresh install with another domain, but nothing worked.

--- Update ---
These are the logs from the Vercel Function

2021-04-24T11:33:12.059Z	98af8993-a76a-4b4e-84bc-ac573df67be9	ERROR	Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:558:11)
    at sendJson (/var/task/node_modules/next/dist/next-server/server/api-utils.js:37:5)
    at ServerResponse.apiRes.json (/var/task/node_modules/next/dist/next-server/server/api-utils.js:6:297)
    at webhook_handler (/var/task/.next/serverless/pages/api/stripe/webhook.js:423:21)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async apiResolver (/var/task/node_modules/next/dist/next-server/server/api-utils.js:8:1)
    at async /var/task/.next/serverless/pages/api/stripe/webhook.js:137:387 {
  code: 'ERR_HTTP_HEADERS_SENT'
}
2021-04-24T11:33:12.060Z	98af8993-a76a-4b4e-84bc-ac573df67be9	ERROR	Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:558:11)
    at sendJson (/var/task/node_modules/next/dist/next-server/server/api-utils.js:37:5)
    at ServerResponse.apiRes.json (/var/task/node_modules/next/dist/next-server/server/api-utils.js:6:297)
    at webhook_handler (/var/task/.next/serverless/pages/api/stripe/webhook.js:423:21)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async apiResolver (/var/task/node_modules/next/dist/next-server/server/api-utils.js:8:1)
    at async /var/task/.next/serverless/pages/api/stripe/webhook.js:137:387 {
  code: 'ERR_HTTP_HEADERS_SENT'
}
2021-04-24T11:33:12.061Z	98af8993-a76a-4b4e-84bc-ac573df67be9	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client","reason":{"errorType":"Error","errorMessage":"Cannot set headers after they are sent to the client","code":"ERR_HTTP_HEADERS_SENT","stack":["Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client","    at ServerResponse.setHeader (_http_outgoing.js:558:11)","    at sendJson (/var/task/node_modules/next/dist/next-server/server/api-utils.js:37:5)","    at ServerResponse.apiRes.json (/var/task/node_modules/next/dist/next-server/server/api-utils.js:6:297)","    at webhook_handler (/var/task/.next/serverless/pages/api/stripe/webhook.js:423:21)","    at processTicksAndRejections (internal/process/task_queues.js:93:5)","    at async apiResolver (/var/task/node_modules/next/dist/next-server/server/api-utils.js:8:1)","    at async /var/task/.next/serverless/pages/api/stripe/webhook.js:137:387"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:327:22)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:94:32)"]}
Unknown application error occurred

Update --
The error was caused by a required variable in the Order Schema, the fastest fix is making the variable non-required in the schema.
I'll try to fix it without making the variable non-required, anyways i'm going to close the issue.

commented

@ynnoj Does this no longer easily connect to Printful like the original project did? https://github.com/GraphCMS/gatsby-graphcms-ecommerce-starter/blob/master/.env.sample