-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Describe the Bug
Fresh deploys created from the new Payload Cloudflare Template fail during the deploy:database step. Running payload migrate against D1 in the Cloudflare build environment times out with an Undici HeadersTimeoutError coming via Miniflare’s proxy.
The Cloudflare account uses the paid Workers.
Logs
2025-10-12T07:13:35.102Z Initializing build environment...
2025-10-12T07:13:44.618Z Success: Finished initializing build environment
2025-10-12T07:13:44.740Z Cloning seed repository...
2025-10-12T07:13:44.753Z Cloning from: https://github.com/payloadcms/payload.git
2025-10-12T07:13:48.495Z Overwriting files
2025-10-12T07:13:48.834Z Pushing to destination: https://github.com/redacted/redacted.git
2025-10-12T07:13:51.317Z Detected the following tools from environment: [email protected], [email protected]
2025-10-12T07:13:51.320Z Installing project dependencies: bun install
2025-10-12T07:13:51.550Z bun install v1.2.15 (df017990)
2025-10-12T07:13:51.607Z Resolving dependencies
2025-10-12T07:14:00.008Z Resolved, downloaded and extracted [4296]
2025-10-12T07:14:40.904Z Saved lockfile
2025-10-12T07:14:40.907Z
2025-10-12T07:14:40.907Z + @playwright/[email protected] (v1.56.0 available)
2025-10-12T07:14:40.907Z + @testing-library/[email protected]
2025-10-12T07:14:40.907Z + @types/[email protected] (v24.7.2 available)
2025-10-12T07:14:40.907Z + @types/[email protected] (v19.2.2 available)
2025-10-12T07:14:40.907Z + @types/[email protected] (v19.2.1 available)
2025-10-12T07:14:40.914Z + @vitejs/[email protected] (v5.0.4 available)
2025-10-12T07:14:40.914Z + [email protected]
2025-10-12T07:14:40.914Z + [email protected] (v15.5.4 available)
2025-10-12T07:14:40.914Z + [email protected] (v27.0.0 available)
2025-10-12T07:14:40.915Z + [email protected] (v1.56.0 available)
2025-10-12T07:14:40.915Z + [email protected] (v1.56.0 available)
2025-10-12T07:14:40.915Z + [email protected]
2025-10-12T07:14:40.915Z + [email protected] (v5.9.3 available)
2025-10-12T07:14:40.916Z + [email protected]
2025-10-12T07:14:40.916Z + [email protected] (v3.2.4 available)
2025-10-12T07:14:40.917Z + [email protected]
2025-10-12T07:14:40.917Z + @opennextjs/[email protected]
2025-10-12T07:14:40.917Z + @payloadcms/[email protected]
2025-10-12T07:14:40.917Z + @payloadcms/[email protected]
2025-10-12T07:14:40.918Z + @payloadcms/[email protected]
2025-10-12T07:14:40.918Z + @payloadcms/[email protected]
2025-10-12T07:14:40.918Z + @payloadcms/[email protected]
2025-10-12T07:14:40.919Z + [email protected] (v10.1.0 available)
2025-10-12T07:14:40.919Z + [email protected] (v17.2.3 available)
2025-10-12T07:14:40.919Z + [email protected]
2025-10-12T07:14:40.920Z + [email protected] (v15.5.4 available)
2025-10-12T07:14:40.920Z + [email protected]
2025-10-12T07:14:40.920Z + [email protected] (v19.2.0 available)
2025-10-12T07:14:40.921Z + [email protected] (v19.2.0 available)
2025-10-12T07:14:40.921Z
2025-10-12T07:14:40.923Z 1094 packages installed [49.43s]
2025-10-12T07:14:40.923Z
2025-10-12T07:14:40.923Z Blocked 1 postinstall. Run bun pm untrusted
for details.
2025-10-12T07:14:40.993Z Executing user build command: npm run build
2025-10-12T07:14:41.306Z
2025-10-12T07:14:41.307Z > [email protected] build
2025-10-12T07:14:41.307Z > cross-env NODE_OPTIONS="--no-deprecation --max-old-space-size=8000" next build
2025-10-12T07:14:41.307Z
2025-10-12T07:14:42.394Z ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
2025-10-12T07:14:42.398Z Attention: Next.js now collects completely anonymous telemetry regarding usage.
2025-10-12T07:14:42.398Z This information is used to shape Next.js' roadmap and prioritize features.
2025-10-12T07:14:42.398Z You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
2025-10-12T07:14:42.398Z https://nextjs.org/telemetry
2025-10-12T07:14:42.398Z
2025-10-12T07:14:42.511Z ▲ Next.js 15.4.4
2025-10-12T07:14:42.511Z
2025-10-12T07:14:42.525Z Creating an optimized production build ...
2025-10-12T07:15:26.198Z ✓ Compiled successfully in 43s
2025-10-12T07:15:26.217Z Linting and checking validity of types ...
2025-10-12T07:15:28.807Z
2025-10-12T07:15:28.808Z ./src/app/my-route/route.ts
2025-10-12T07:15:28.808Z 4:27 Warning: 'request' is defined but never used. Allowed unused args must match /^/u. @typescript-eslint/no-unused-vars
2025-10-12T07:15:28.809Z 5:9 Warning: 'payload' is assigned a value but never used. Allowed unused vars must match /^/u. @typescript-eslint/no-unused-vars
2025-10-12T07:15:28.809Z
2025-10-12T07:15:28.809Z ./src/migrations/20250929_111647.ts
2025-10-12T07:15:28.809Z 3:32 Warning: 'payload' is defined but never used. Allowed unused args must match /^/u. @typescript-eslint/no-unused-vars
2025-10-12T07:15:28.809Z 3:41 Warning: 'req' is defined but never used. Allowed unused args must match /^/u. @typescript-eslint/no-unused-vars
2025-10-12T07:15:28.809Z 148:34 Warning: 'payload' is defined but never used. Allowed unused args must match /^/u. @typescript-eslint/no-unused-vars
2025-10-12T07:15:28.809Z 148:43 Warning: 'req' is defined but never used. Allowed unused args must match /^/u. @typescript-eslint/no-unused-vars
2025-10-12T07:15:28.809Z
2025-10-12T07:15:28.809Z info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules
2025-10-12T07:15:31.217Z Collecting page data ...
2025-10-12T07:15:37.697Z Generating static pages (0/7) ...
2025-10-12T07:15:38.489Z Generating static pages (1/7)
2025-10-12T07:15:38.490Z Generating static pages (3/7)
2025-10-12T07:15:40.404Z Generating static pages (5/7)
2025-10-12T07:15:40.404Z ✓ Generating static pages (7/7)
2025-10-12T07:15:40.978Z Finalizing page optimization ...
2025-10-12T07:15:40.980Z Collecting build traces ...
2025-10-12T07:15:48.079Z
2025-10-12T07:15:48.082Z Route (app) Size First Load JS
2025-10-12T07:15:48.082Z ┌ ƒ / 5.46 kB 106 kB
2025-10-12T07:15:48.082Z ├ ○ /_not-found 999 B 102 kB
2025-10-12T07:15:48.082Z ├ ƒ /admin/[[...segments]] 369 B 536 kB
2025-10-12T07:15:48.082Z ├ ƒ /api/[...slug] 177 B 101 kB
2025-10-12T07:15:48.082Z ├ ƒ /api/graphql 133 B 101 kB
2025-10-12T07:15:48.082Z ├ ƒ /api/graphql-playground 177 B 101 kB
2025-10-12T07:15:48.082Z └ ƒ /my-route 133 B 101 kB
2025-10-12T07:15:48.082Z + First Load JS shared by all 101 kB
2025-10-12T07:15:48.082Z ├ chunks/4bd1b696-cc729d47eba2cee4.js 54.1 kB
2025-10-12T07:15:48.082Z ├ chunks/5964-4f12b6422f73cb12.js 43.9 kB
2025-10-12T07:15:48.082Z └ other shared chunks (total) 2.71 kB
2025-10-12T07:15:48.082Z
2025-10-12T07:15:48.082Z
2025-10-12T07:15:48.082Z ○ (Static) prerendered as static content
2025-10-12T07:15:48.082Z ƒ (Dynamic) server-rendered on demand
2025-10-12T07:15:48.082Z
2025-10-12T07:15:48.236Z Success: Build command completed
2025-10-12T07:15:48.236Z Executing user deploy command: npm run deploy
2025-10-12T07:15:48.434Z
2025-10-12T07:15:48.434Z > [email protected] deploy
2025-10-12T07:15:48.434Z > pnpm run deploy:database && pnpm run deploy:app
2025-10-12T07:15:48.434Z
2025-10-12T07:15:48.878Z
2025-10-12T07:15:48.878Z > [email protected] deploy:database /opt/buildhome/repo
2025-10-12T07:15:48.878Z > cross-env NODE_ENV=production PAYLOAD_SECRET=ignore payload migrate && wrangler d1 execute D1 --command 'PRAGMA optimize' --env=$CLOUDFLARE_ENV --remote
2025-10-12T07:15:48.878Z
2025-10-12T07:15:53.439Z [07:15:53] WARN: No email adapter provided. Email will be written to console. More info at https://payloadcms.com/docs/email/overview.
2025-10-12T07:15:53.441Z [07:15:53] INFO: Reading migration files from /opt/buildhome/repo/src/migrations
2025-10-12T07:20:54.253Z /opt/buildhome/repo/node_modules/src/sqlite-core/session.ts:81
2025-10-12T07:20:54.253Z throw new DrizzleQueryError(queryString, params, e as Error);
2025-10-12T07:20:54.253Z ^
2025-10-12T07:20:54.253Z
2025-10-12T07:20:54.253Z
2025-10-12T07:20:54.253Z DrizzleQueryError: Failed query:
2025-10-12T07:20:54.253Z SELECT CASE
2025-10-12T07:20:54.253Z WHEN COUNT() > 0 THEN 1
2025-10-12T07:20:54.254Z ELSE 0
2025-10-12T07:20:54.254Z END AS 'exists'
2025-10-12T07:20:54.254Z FROM sqlite_master
2025-10-12T07:20:54.254Z WHERE type = 'table'
2025-10-12T07:20:54.254Z AND name = 'payload_migrations';
2025-10-12T07:20:54.254Z params:
2025-10-12T07:20:54.254Z at D1PreparedQuery.queryWithCache (/opt/buildhome/repo/node_modules/src/sqlite-core/session.ts:81:11)
2025-10-12T07:20:54.254Z at async D1PreparedQuery.run (/opt/buildhome/repo/node_modules/src/d1/session.ts:202:10)
2025-10-12T07:20:54.254Z ... 3 lines matching cause stack trace ...
2025-10-12T07:20:54.254Z at async migrate (/opt/buildhome/repo/node_modules/payload/src/bin/migrate.ts:87:7)
2025-10-12T07:20:54.255Z at async runBinScript (/opt/buildhome/repo/node_modules/payload/dist/bin/index.js:112:9)
2025-10-12T07:20:54.255Z at async bin (/opt/buildhome/repo/node_modules/payload/dist/bin/index.js:45:29)
2025-10-12T07:20:54.255Z at async start (file:///opt/buildhome/repo/node_modules/payload/bin.js:30:7) {
2025-10-12T07:20:54.255Z query: '\n' +
2025-10-12T07:20:54.255Z ' SELECT CASE\n' +
2025-10-12T07:20:54.255Z ' WHEN COUNT() > 0 THEN 1\n' +
2025-10-12T07:20:54.255Z ' ELSE 0\n' +
2025-10-12T07:20:54.255Z " END AS 'exists'\n" +
2025-10-12T07:20:54.255Z ' FROM sqlite_master\n' +
2025-10-12T07:20:54.255Z " WHERE type = 'table'\n" +
2025-10-12T07:20:54.255Z " AND name = 'payload_migrations';",
2025-10-12T07:20:54.255Z params: [],
2025-10-12T07:20:54.255Z cause: TypeError: fetch failed
2025-10-12T07:20:54.255Z at Object.fetch (/opt/buildhome/repo/node_modules/miniflare/node_modules/undici/index.js:124:13)
2025-10-12T07:20:54.255Z at async fetch4 (/opt/buildhome/repo/node_modules/miniflare/src/http/fetch.ts:83:19)
2025-10-12T07:20:54.255Z at async ProxyClientBridge.dispatchFetch (/opt/buildhome/repo/node_modules/miniflare/src/index.ts:2414:20)
2025-10-12T07:20:54.255Z at async ProxyStubHandler.#parseAsyncResponse (/opt/buildhome/repo/node_modules/miniflare/src/plugins/core/proxy/client.ts:404:15)
2025-10-12T07:20:54.255Z at async D1PreparedQuery.queryWithCache (/opt/buildhome/repo/node_modules/src/sqlite-core/session.ts:79:12)
2025-10-12T07:20:54.255Z at async D1PreparedQuery.run (/opt/buildhome/repo/node_modules/src/d1/session.ts:202:10)
2025-10-12T07:20:54.255Z at async QueryPromise.query.execute (/opt/buildhome/repo/node_modules/@payloadcms/db-d1-sqlite/src/execute.ts:45:32)
2025-10-12T07:20:54.255Z at async migrationTableExists (/opt/buildhome/repo/node_modules/@payloadcms/drizzle/src/utilities/migrationTableExists.ts:27:18)
2025-10-12T07:20:54.255Z at async Object.migrate (/opt/buildhome/repo/node_modules/@payloadcms/drizzle/src/migrate.ts:37:29)
2025-10-12T07:20:54.255Z at async migrate (/opt/buildhome/repo/node_modules/payload/src/bin/migrate.ts:87:7) {
2025-10-12T07:20:54.255Z [cause]: HeadersTimeoutError: Headers Timeout Error
2025-10-12T07:20:54.255Z at FastTimer.onParserTimeout [as _onTimeout] (/opt/buildhome/repo/node_modules/miniflare/node_modules/undici/lib/dispatcher/client-h1.js:746:28)
2025-10-12T07:20:54.255Z at Timeout.onTick [as _onTimeout] (/opt/buildhome/repo/node_modules/miniflare/node_modules/undici/lib/util/timers.js:162:13)
2025-10-12T07:20:54.255Z at listOnTimeout (node:internal/timers:588:17)
2025-10-12T07:20:54.255Z at process.processTimers (node:internal/timers:523:7) {
2025-10-12T07:20:54.256Z code: 'UND_ERR_HEADERS_TIMEOUT'
2025-10-12T07:20:54.256Z }
2025-10-12T07:20:54.256Z }
2025-10-12T07:20:54.256Z }
2025-10-12T07:20:54.256Z
2025-10-12T07:20:54.256Z Node.js v22.16.0
2025-10-12T07:20:54.300Z ELIFECYCLE Command failed with exit code 1.
2025-10-12T07:20:55.075Z Failed: error occurred while running deploy command
Link to the code that reproduces this issue
https://github.com/payloadcms/payload/tree/main/templates/with-cloudflare-d1
Reproduction Steps
- Scaffold a project from the Payload Cloudflare Template.
- Assign names for project, R2, D1 and a value for the PAYLOAD_SECRET
Observe failure during pnpm run deploy:database (the payload migrate part).
Which area(s) are affected? (Select all that apply)
Not sure, db: d1-sqlite
Environment Info
Node.js v22.16.0
next 15.4.4
payload 3.59.1
Cloudflare Workers: Paid