gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

ERROR #98001 ENGINE.VALIDATION - Build Fail - Cloud Function Raw Request Implementation #38465

Open CloudBop opened 1 year ago

CloudBop commented 1 year ago

Preliminary Checks

Description

Howdy,

I'll try and be brief. I'm getting this troublesome error. Frustratingly, It's one of those errors that happens right at the end of the build process. My laptop hates me and is trying to fly away. I've resorted to using an External HDD to throttle the build process in order to tame the fans.

Here it is...

failed Validating Rendering Engines - 6.703s

 ERROR #98001  ENGINE.VALIDATION

Built Rendering Engines failed validation.

Please open an issue with a reproduction at https://gatsby.dev/new-issue for more help.

  Error: Worker exited before finishing task

  - index.js:205 ChildProcess.<anonymous>
    [gatsby-fh-app]/[gatsby-worker]/dist/index.js:205:41

It seems to be being caused by the export const config implementation which I am using as to attempt this tutorial -> Stripe webhook verification in a Gatsby Serverless Function - https://www.youtube.com/watch?v=Wqilgl_V7FA

//  If const config Object literal is commented out, the build process succeeds
export const config = {
  bodyParser: {
    raw: {
      type: `*/*`,
    },
  },
};

export default function handler(req, res) {
  res.status(200).json({ hello: `world` })
}

I think I'm following the correct implementation and syntax from the documentation below, but no success as of yet.

https://www.gatsbyjs.com/docs/reference/functions/middleware-and-helpers/

I'm in the process of trying to recreate the error but as the site is abstracted out across a few themes (and their own plugins) it's not so easy to recreate. I will keep on persevering to recreate the error but this error is tricky to track/recreate as I have to wait for the build process to get to the failing stage.

If anyone has ideas to what's happening or has any advice with troubleshooting it would be very much appreciated. Perhaps there's a conflict in the order of the plugins or their dependencies / peerDeps. Could it be the order or the workspace dependency array in the root package.json ?

It's really strange how the error only comes about when including code below...

export const config = {
  bodyParser: {
    raw: {
      type: `*/*`,
    },
  },
};

...in an cloud API function. It doesn't matter whether the function is created in a gatsby-theme/src/api/gatsby-theme or the consuming site API. I get the same error.

I'm really confused as I suppose that the build error itself is probably being caused by something other than the Gatsby-function implementation. But Without the export config the site builds ok and everything works fine in dev mode.

Thanks

Reproduction Link

https://github.com/CloudBop/gatsby-func-cloud-raw

Steps to Reproduce

I am in the process of trying to recreate this error.

Expected Result

Using the named export config {} and bodyParser with a cloud function should allow for rawHeaders to be received in buffer form and should also build successfully.

Actual Result

When running "build": "gatsby build --verbose", get the error


failed Validating Rendering Engines - 6.747s

 ERROR #98001  ENGINE.VALIDATION

Built Rendering Engines failed validation.

Please open an issue with a reproduction at https://gatsby.dev/new-issue for more help.

  Error: Worker exited before finishing task

  - index.js:205 ChildProcess.<anonymous>
    [gatsby-cra-loadable-experiments]/[gatsby-worker]/dist/index.js:205:41

error Command failed with exit code 1.

Environment

System:
    OS: macOS 12.6.7
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  Languages:
    Python: 3.7.4 - /Users/c********/opt/anaconda3/bin/python
  Browsers:
    Chrome: 115.0.5790.170
    Firefox: 116.0.3
    Safari: 16.5.2
  npmGlobalPackages:
    gatsby-cli: 5.3.1

Config Flags

No response

CloudBop commented 1 year ago

As danyim mentioned this issue seems to be related to https://github.com/gatsbyjs/gatsby/issues/38467

Rolling back to 7.9.0 (at least for me) 'fixes' both of these issues.

Mellis84 commented 8 months ago

I get this issue when using getServerData() to create SSR pages. Desperate for a solution here.

vipinamethi commented 6 months ago

I am getting same issue in one of my project

I am using 7.9.0 image