gatsbyjs / gatsby

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

gatsby-source-contentful with DSG on a page giving error when accessed from Vercel #38972

Open 7sferry opened 1 month ago

7sferry commented 1 month ago

Preliminary Checks

Description

When using Gatsby Source Contentful plugin and apply DSG on a page that using Graphql from Contentful on Vercel, then that page will be error. If DSG applied to a page without Graphql from Contentful, it can be viewed without error.

Reproduction Link

https://github.com/7sferry/contentful-gatsby-reproduction

Steps to Reproduce

  1. use "gatsby-source-contentful": "^8.13.1" plugin
  2. render a page using DSG that contains GraphQL from Contentful like:
    query ArchiveQuery {
    allContentfulBlogPost(sort: { publishDate: DESC }) {
      nodes {
        slug
        title
        publishDate
      }
    }
    }
  3. deploy it on vercel.
  4. access that page and it will result error 500.

Expected Result

DSG page run without error with contentful on vercel and the page can be viewed

Actual Result

the page with DSR that contains graphql from contentful cannot be viewed and the runtime log writes: error "gatsby-source-contentful" threw an error while running the createSchemaCustomization lifecycle: ENOENT: no such file or directory, mkdir '/var/task/.cache/caches-lmdb'   Error: ENOENT: no such file or directory, mkdir '/var/task/.cache/caches-lmdb'   - node:fs:1373 Object.mkdirSync   node:fs:1373:26    - index.js:2224 open   /var/task/.cache/query-engine/index.js:2224:6    - index.js:142 Function.getStore   /var/task/.cache/query-engine/index.js:142:29    - index.js:153 GatsbyCacheLmdb.getDb   /var/task/.cache/query-engine/index.js:153:33    - index.js:164 GatsbyCacheLmdb.set   /var/task/.cache/query-engine/index.js:164:16    - index.js:298372 getContentTypesFromContentful   /var/task/.cache/query-engine/index.js:298372:15    - task_queues:95 processTicksAndRejections   node:internal/process/task_queues:95:5    - index.js:298393 Module.createSchemaCustomization   /var/task/.cache/query-engine/index.js:298393:24    - index.js:261017 runAPI   /var/task/.cache/query-engine/index.js:261017:16    Unhandled Rejection: Error: Schema must contain uniquely named types but contains multiple types named "ImageResizingBehavior". at new GraphQLSchema (/var/task/.cache/query-engine/index.js:97724:15) at SchemaComposer.buildSchema (/var/task/.cache/query-engine/index.js:121218:16) at addCustomResolveFunctions (/var/task/.cache/query-engine/index.js:272943:45) at updateSchemaComposer (/var/task/.cache/query-engine/index.js:272322:9) at buildSchema (/var/task/.cache/query-engine/index.js:272218:3) at build (/var/task/.cache/query-engine/index.js:30354:18) at GraphQLEngine._doGetRunner (/var/task/.cache/query-engine/index.js:363721:7) Unhandled Rejection: Error: Schema must contain uniquely named types but contains multiple types named "ImageResizingBehavior". at new GraphQLSchema (/var/task/.cache/query-engine/index.js:97724:15) at SchemaComposer.buildSchema (/var/task/.cache/query-engine/index.js:121218:16) at addCustomResolveFunctions (/var/task/.cache/query-engine/index.js:272943:45) at updateSchemaComposer (/var/task/.cache/query-engine/index.js:272322:9) at buildSchema (/var/task/.cache/query-engine/index.js:272218:3) at build (/var/task/.cache/query-engine/index.js:30354:18) at GraphQLEngine._doGetRunner (/var/task/.cache/query-engine/index.js:363721:7) Node.js process exited with exit status: 128. The logs above can help with debugging the issue. Unknown application error occurred

Environment

System:
    OS: Linux 5.10 Amazon Linux 2023
    CPU: (2) x64 Intel(R) Xeon(R) Processor @ 2.90GHz
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.12.2 - /node20/bin/node
    Yarn: 4.1.1 - /yarn1/node_modules/yarn/bin/yarn
    npm: 10.5.0 - /node20/bin/npm
  npmPackages:
    gatsby: ^5.13.3 => 5.13.4 
    gatsby-plugin-algolia: ^1.0.3 => 1.0.3 
    gatsby-plugin-catch-links: ^5.13.1 => 5.13.1 
    gatsby-plugin-google-analytics-data-reporting-api: ^1.3.1 => 1.3.1 
    gatsby-plugin-google-gtag: ^5.13.1 => 5.13.1 
    gatsby-plugin-image: ^3.13.1 => 3.13.1 
    gatsby-plugin-manifest: ^5.13.1 => 5.13.1 
    gatsby-plugin-offline: ^6.13.1 => 6.13.2 
    gatsby-plugin-purgecss: ^6.2.1 => 6.2.1 
    gatsby-plugin-sharp: ^5.13.1 => 5.13.1 
    gatsby-plugin-sitemap: ^6.13.1 => 6.13.1 
    gatsby-remark-images-contentful: ^6.13.1 => 6.13.1 
    gatsby-remark-prismjs: ^7.13.1 => 7.13.1 
    gatsby-source-contentful: ^8.13.1 => 8.13.1 
    gatsby-source-filesystem: ^5.13.1 => 5.13.1 
    gatsby-transformer-remark: ^6.13.1 => 6.13.1 
    gatsby-transformer-sharp: ^5.13.1 => 5.13.1

Config Flags

-