payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
28.04k stars 1.74k forks source link

create-payload-app@beta data seeding broken #8879

Open stevekuznetsov opened 4 weeks ago

stevekuznetsov commented 4 weeks ago

Describe the Bug

I created a brand-new app and connected to a Vercel-managed Postgres instance. I opened the admin panel and clicked the seed button. Seeding fails with this error while adding the related posts to the first post:

[16:01:02] ERROR: Error validating filter options for collection posts
    err: {
      "type": "NotFound",
      "message": "Not Found",
      "stack":
          NotFound: Not Found
              at findByIDOperation (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/collections/operations/findByID.js:70:23)
              at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
              at async populateAuthors (webpack-internal:///(rsc)/./src/collections/Posts/hooks/populateAuthors.ts:13:31)
              at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/collections/operations/find.js:205:30)
              at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/collections/operations/find.js:203:17)
              at async Promise.all (index 1)
              at async findOperation (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/collections/operations/find.js:201:19)
              at async validateFilterOptions (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/fields/validations.js:404:36)
              at async promise (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/fields/hooks/beforeChange/promise.js:84:38)
              at async Promise.all (index 0)
              at async traverseFields (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/fields/hooks/beforeChange/traverseFields.js:38:5)
              at async promise (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/fields/hooks/beforeChange/promise.js:309:17)
              at async Promise.all (index 1)
              at async traverseFields (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/fields/hooks/beforeChange/traverseFields.js:38:5)
              at async promise (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/fields/hooks/beforeChange/promise.js:333:17)
              at async Promise.all (index 1)
              at async traverseFields (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/fields/hooks/beforeChange/traverseFields.js:38:5)
              at async beforeChange (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/fields/hooks/beforeChange/index.js:22:5)
              at async updateByIDOperation (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.0.0-beta.119_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241_cawqsxv2rsw3o2qcs57mgzb6au/node_modules/payload/dist/collections/operations/updateByID.js:253:22)
              at async seed (webpack-internal:///(rsc)/./src/endpoints/seed/index.ts:267:5)
              at async Object.seedHandler [as handler] (webpack-internal:///(rsc)/./src/endpoints/seedHandler.ts:22:9)
              at async handleCustomEndpoints (webpack-internal:///(rsc)/./node_modules/.pnpm/@payloadcms+next@3.0.0-beta.119_bufferutil@4.0.8_graphql@16.9.0_monaco-editor@0.52.0_next@15._wfgcrxf5fm4ki4drr4c2hbztpi/node_modules/@payloadcms/next/dist/routes/rest/index.js:198:19)
              at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@payloadcms+next@3.0.0-beta.119_bufferutil@4.0.8_graphql@16.9.0_monaco-editor@0.52.0_next@15._wfgcrxf5fm4ki4drr4c2hbztpi/node_modules/@payloadcms/next/dist/routes/rest/index.js:420:36)
              at async AppRouteRouteModule.do (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:10:32709)
              at async AppRouteRouteModule.handle (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:10:38210)
              at async doRender (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/base-server.js:1493:42)
              at async responseGenerator (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/base-server.js:1834:28)
              at async DevServer.renderToResponseWithComponentsImpl (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/base-server.js:1878:28)
              at async DevServer.renderPageComponent (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/base-server.js:2292:24)
              at async DevServer.renderToResponseImpl (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/base-server.js:2330:32)
              at async DevServer.pipeImpl (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/base-server.js:984:25)
              at async NextNodeServer.handleCatchallRenderRequest (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/next-server.js:281:17)
              at async DevServer.handleRequestImpl (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/base-server.js:877:17)
              at async /home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/dev/next-dev-server.js:373:20
              at async Span.traceAsyncFn (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/trace/trace.js:157:20)
              at async DevServer.handleRequest (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/dev/next-dev-server.js:370:24)
              at async invokeRender (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/lib/router-server.js:183:21)
              at async handleRequest (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/lib/router-server.js:360:24)
              at async requestHandlerImpl (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/lib/router-server.js:384:13)
              at async Server.requestListener (/home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/lib/start-server.js:142:13)
      "data": null,
      "isOperational": true,
      "isPublic": false,
      "status": 404,
      "name": "NotFound"
    }
 GET /api/seed 500 in 20353ms
[16:01:02] ERROR: The following field is invalid: relatedPosts

I've added loads of debugging information and I can fetch all of the posts, cycle through them and execute the meat of the populateAuthors logic - fetching the authors - with no issue whatsoever. As far as I can tell there is nothing in the posts table after this script runs and fails.

Link to the code that reproduces this issue

https://github.com/NWACus/website/commit/5a9b520f30b86b663f57cb0334c90930189402eb#diff-ec70d248db3563b095d5b75fc9c001d30a315e4b2e01e920277bb1c1261adfe5R238

Reproduction Steps

npx create-payload-app@beta website -t website
# use the Vercel Postgres option for storage, add a connection string
pnpm install && pnpm dev
# open the admin panel and click on seed

Which area(s) are affected? (Select all that apply)

area: templates

Environment Info

$ pnpm payload info

    website@1.0.0 payload /home/stevekuznetsov/code/NWACus/website/src/github.com/NWACus/website
    cross-env NODE_OPTIONS=--no-deprecation payload "info"

Binaries:
Node: 20.17.0
npm: 10.8.2
Yarn: 1.22.22
pnpm: 9.12.2
Relevant Packages:
payload: 3.0.0-beta.119
next: 15.0.0
@payloadcms/email-nodemailer: 3.0.0-beta.119
@payloadcms/graphql: 3.0.0-beta.119
@payloadcms/live-preview: 3.0.0-beta.119
@payloadcms/live-preview-react: 3.0.0-beta.119
@payloadcms/next/utilities: 3.0.0-beta.119
@payloadcms/payload-cloud: 3.0.0-beta.119
@payloadcms/plugin-form-builder: 3.0.0-beta.119
@payloadcms/plugin-nested-docs: 3.0.0-beta.119
@payloadcms/plugin-redirects: 3.0.0-beta.119
@payloadcms/plugin-search: 3.0.0-beta.119
@payloadcms/plugin-seo: 3.0.0-beta.119
@payloadcms/richtext-lexical: 3.0.0-beta.119
@payloadcms/translations: 3.0.0-beta.119
@payloadcms/ui/shared: 3.0.0-beta.119
react: 19.0.0-rc-65a56d0e-20241020
react-dom: 19.0.0-rc-65a56d0e-20241020
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Thu Oct 10 22:31:19 UTC 2024
Available memory (MB): 64191
Available CPU cores: 16
r1tsuu commented 3 weeks ago

Hey! We couldn't reproduce your issue, I tried:

benloeffel commented 2 weeks ago

Hey @stevekuznetsov & @r1tsuu!

I've also encountered this exact issue during a new project setup today.

Steps to Reproduce:

  1. Created a fresh PostgreSQL database on Vercel and copied the connection string postgres://default:************@************:5432/verceldb?sslmode=require.
  2. Created a new directory and ran npx create-payload-app@beta -t website.
  3. Entered project name, selected database "Vercel Postgres (beta)", pasted Vercel connection string and waited for installation to complete.
  4. Started app with pnpm dev.
  5. Visited localhost:3000/admin, created a new user, and logged in.
  6. Clicked the seed database link, which after a few seconds showed that the seeding was successful, but the console returned the following:
    [15:27:39] INFO: Seeding database...
    [15:27:39] INFO: — Clearing media...
    [15:27:39] INFO: — Clearing collections and globals...
    [15:27:39] INFO: Revalidating header
    [15:27:39] INFO: Revalidating footer
    { pages: { docs: [], errors: [] } }
    [15:27:40] INFO: — Seeding demo author and user...
    [15:27:41] INFO: — Seeding media...
    [15:27:42] INFO: — Seeding categories...
    [15:27:45] INFO: — Seeding posts...
    [15:27:46] INFO: Revalidating post at path: /posts/digital-horizons
    [15:27:46] INFO: Revalidating post at path: /posts/global-gaze
    [15:27:47] INFO: Revalidating post at path: /posts/dollar-and-sense-the-financial-forecast
    [15:27:48] ERROR: Error validating filter options for collection posts
    err: {
      "type": "NotFound",
      "message": "Not Found",
      "stack":
          NotFound: Not Found
              at findByIDOperation (webpack-internal:///(rsc)/./node_modules/payload/dist/collections/operations/findByID.js:71:23)
              at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
              at async populateAuthors (webpack-internal:///(rsc)/./src/collections/Posts/hooks/populateAuthors.ts:13:31)
              at async eval (webpack-internal:///(rsc)/./node_modules/payload/dist/collections/operations/find.js:230:30)
              at async eval (webpack-internal:///(rsc)/./node_modules/payload/dist/collections/operations/find.js:228:17)
              at async Promise.all (index 1)
              at async findOperation (webpack-internal:///(rsc)/./node_modules/payload/dist/collections/operations/find.js:226:19)
              at async validateFilterOptions (webpack-internal:///(rsc)/./node_modules/payload/dist/fields/validations.js:404:36)
              at async promise (webpack-internal:///(rsc)/./node_modules/payload/dist/fields/hooks/beforeChange/promise.js:84:38)
              at async Promise.all (index 0)
              at async traverseFields (webpack-internal:///(rsc)/./node_modules/payload/dist/fields/hooks/beforeChange/traverseFields.js:38:5)
              at async promise (webpack-internal:///(rsc)/./node_modules/payload/dist/fields/hooks/beforeChange/promise.js:309:17)
              at async Promise.all (index 1)
              at async traverseFields (webpack-internal:///(rsc)/./node_modules/payload/dist/fields/hooks/beforeChange/traverseFields.js:38:5)
              at async promise (webpack-internal:///(rsc)/./node_modules/payload/dist/fields/hooks/beforeChange/promise.js:333:17)
              at async Promise.all (index 1)
              at async traverseFields (webpack-internal:///(rsc)/./node_modules/payload/dist/fields/hooks/beforeChange/traverseFields.js:38:5)
              at async beforeChange (webpack-internal:///(rsc)/./node_modules/payload/dist/fields/hooks/beforeChange/index.js:22:5)
              at async updateByIDOperation (webpack-internal:///(rsc)/./node_modules/payload/dist/collections/operations/updateByID.js:253:22)
              at async seed (webpack-internal:///(rsc)/./src/endpoints/seed/index.ts:225:5)
              at async Object.seedHandler [as handler] (webpack-internal:///(rsc)/./src/endpoints/seedHandler.ts:22:9)
              at async handleCustomEndpoints (webpack-internal:///(rsc)/./node_modules/@payloadcms/next/dist/routes/rest/index.js:198:19)
              at async eval (webpack-internal:///(rsc)/./node_modules/@payloadcms/next/dist/routes/rest/index.js:420:36)
              at async AppRouteRouteModule.do (/home/ben/projects/bato-web-app/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:10:32709)
              at async AppRouteRouteModule.handle (/home/ben/projects/bato-web-app/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:10:38210)
              at async doRender (/home/ben/projects/bato-web-app/node_modules/next/dist/server/base-server.js:1493:42)
              at async responseGenerator (/home/ben/projects/bato-web-app/node_modules/next/dist/server/base-server.js:1834:28)
              at async DevServer.renderToResponseWithComponentsImpl (/home/ben/projects/bato-web-app/node_modules/next/dist/server/base-server.js:1878:28)
              at async DevServer.renderPageComponent (/home/ben/projects/bato-web-app/node_modules/next/dist/server/base-server.js:2292:24)
              at async DevServer.renderToResponseImpl (/home/ben/projects/bato-web-app/node_modules/next/dist/server/base-server.js:2330:32)
              at async DevServer.pipeImpl (/home/ben/projects/bato-web-app/node_modules/next/dist/server/base-server.js:984:25)
              at async NextNodeServer.handleCatchallRenderRequest (/home/ben/projects/bato-web-app/node_modules/next/dist/server/next-server.js:281:17)
              at async DevServer.handleRequestImpl (/home/ben/projects/bato-web-app/node_modules/next/dist/server/base-server.js:877:17)
              at async /home/ben/projects/bato-web-app/node_modules/next/dist/server/dev/next-dev-server.js:373:20
              at async Span.traceAsyncFn (/home/ben/projects/bato-web-app/node_modules/next/dist/trace/trace.js:157:20)
              at async DevServer.handleRequest (/home/ben/projects/bato-web-app/node_modules/next/dist/server/dev/next-dev-server.js:370:24)
              at async invokeRender (/home/ben/projects/bato-web-app/node_modules/next/dist/server/lib/router-server.js:183:21)
              at async handleRequest (/home/ben/projects/bato-web-app/node_modules/next/dist/server/lib/router-server.js:360:24)
              at async requestHandlerImpl (/home/ben/projects/bato-web-app/node_modules/next/dist/server/lib/router-server.js:384:13)
              at async Server.requestListener (/home/ben/projects/bato-web-app/node_modules/next/dist/server/lib/start-server.js:142:13)
      "data": null,
      "isOperational": true,
      "isPublic": false,
      "status": 404,
      "name": "NotFound"
    }
    GET /api/seed 500 in 9379ms
    [15:27:48] ERROR: The following field is invalid: relatedPosts

Environment Info

Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: 1.22.22
  pnpm: 9.4.0
Relevant Packages:
  payload: 3.0.0-beta.123
  next: 15.0.0
  @payloadcms/email-nodemailer: 3.0.0-beta.123
  @payloadcms/graphql: 3.0.0-beta.123
  @payloadcms/live-preview: 3.0.0-beta.123
  @payloadcms/live-preview-react: 3.0.0-beta.123
  @payloadcms/next/utilities: 3.0.0-beta.123
  @payloadcms/payload-cloud: 3.0.0-beta.123
  @payloadcms/plugin-form-builder: 3.0.0-beta.123
  @payloadcms/plugin-nested-docs: 3.0.0-beta.123
  @payloadcms/plugin-redirects: 3.0.0-beta.123
  @payloadcms/plugin-search: 3.0.0-beta.123
  @payloadcms/plugin-seo: 3.0.0-beta.123
  @payloadcms/richtext-lexical: 3.0.0-beta.123
  @payloadcms/translations: 3.0.0-beta.123
  @payloadcms/ui/shared: 3.0.0-beta.123
  react: 19.0.0-rc-65a56d0e-20241020
  react-dom: 19.0.0-rc-65a56d0e-20241020
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
  Available memory (MB): 7866
  Available CPU cores: 12
stevekuznetsov commented 2 weeks ago

Yeah sorry @r1tsuu I don't believe there were any other steps necessary to reproduce this.

stevemarty commented 1 week ago

I have had the same issue. It is erroring out at the following stage of the seeding function: // update each post with related posts await payload.update({ id: post1Doc.id, collection: 'posts', data: { relatedPosts: [post2Doc.id, post3Doc.id], }, req, }) ...

I wonder if it is trying to update the related posts data for each post, before it has actually finished populating each post, so it is requesting post1Doc.id, and that doesn't yet exist?

When I comment out the three related post updates in the seed function it completes the seeding successfully.

I'm also having some slowness issues on even my localhost, so i wonder whether the vercel postgres connection is slow and that is causing the issues.