From 859f6d43100ac58a21265f6b30e41f2b044a4806 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Wed, 21 Oct 2026 10:03:33 -0400 Subject: [PATCH] test(int-suite): auto-accept drizzle push prompts in tests/push-schema.ts payload's pushDevSchema() awaits prompts() whenever drizzle push reports warnings (incl. DATA LOSS); under non-TTY stdin that await hangs forever (2026-10-19 bootstrap hang). Inject confirmations through the single hoisted prompts copy before getPayload boots; stdio stays inherit so all other push output remains visible. --- tests/push-schema.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/push-schema.ts b/tests/push-schema.ts index d56a0036..76380fb2 100644 --- a/tests/push-schema.ts +++ b/tests/push-schema.ts @@ -1,3 +1,5 @@ +// @ts-expect-error - the `prompts` package ships no bundled types; only `.inject()` is used here. +import prompts from "prompts"; import { getPayload } from "payload"; import config from "@payload-config"; @@ -6,7 +8,24 @@ import config from "@payload-config"; * DATABASE_URI pointing at the test database (tests/test-db.ts does this); * initializing the Payload adapter with push: true makes drizzle create or * diff the full schema. Exits immediately after initialization. + * + * Non-interactive by construction: when drizzle push reports warnings + * (including DATA LOSS ones), @payloadcms/drizzle's pushDevSchema asks via + * `prompts()`. Under a non-TTY stdin that await hangs forever, so we pre-load + * the SAME hoisted `prompts` module Payload imports and inject confirmations + * for it. The injected queue never empties in practice (one confirm per run, + * ten prepared); if it ever did, prompts would fall back to stdin, which is + * exactly why the queue is generous rather than exactly one. + * + * This relies on module identity: bun's loader resolves every `import + * prompts from "prompts"` to the single hoisted copy in node_modules (verified + * no nested copies under payload's own node_modules subtree). If a future + * dependency bump nests a second copy, the injection silently stops applying + * and pushes with warnings hang again - watch for that when touching deps. */ +prompts.inject(Array(10).fill(true)); +console.log("[push-schema] non-interactive mode: any drizzle push warnings/data-loss confirmations are auto-accepted"); + const payload = await getPayload({ config }); void payload; process.exit(0);