diff --git a/.changeset/fresh-taxis-pay.md b/.changeset/fresh-taxis-pay.md new file mode 100644 index 000000000..2341b93dd --- /dev/null +++ b/.changeset/fresh-taxis-pay.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/cloudflare": patch +--- + +output more wrangler command logs when the command fails diff --git a/packages/cloudflare/src/cli/utils/run-wrangler.ts b/packages/cloudflare/src/cli/utils/run-wrangler.ts index 7371e3bd3..226ea50b7 100644 --- a/packages/cloudflare/src/cli/utils/run-wrangler.ts +++ b/packages/cloudflare/src/cli/utils/run-wrangler.ts @@ -56,6 +56,8 @@ function injectPassthroughFlagForArgs(options: BuildOptions, args: string[]) { } export function runWrangler(options: BuildOptions, args: string[], wranglerOpts: WranglerOptions = {}) { + const shouldPipeLogs = wranglerOpts.logging === "error"; + const result = spawnSync( options.packager, [ @@ -74,10 +76,9 @@ export function runWrangler(options: BuildOptions, args: string[], wranglerOpts: ], { shell: true, - stdio: wranglerOpts.logging === "error" ? ["ignore", "ignore", "inherit"] : "inherit", + stdio: shouldPipeLogs ? ["ignore", "pipe", "pipe"] : "inherit", env: { ...process.env, - ...(wranglerOpts.logging === "error" ? { WRANGLER_LOG: "error" } : undefined), // `.env` files are handled by the adapter. // Wrangler would load `.env.` while we should load `.env.` // See https://opennext.js.org/cloudflare/howtos/env-vars @@ -87,6 +88,11 @@ export function runWrangler(options: BuildOptions, args: string[], wranglerOpts: ); if (result.status !== 0) { + if (shouldPipeLogs) { + process.stdout.write(result.stdout.toString()); + process.stderr.write(result.stderr.toString()); + } + logger.error("Wrangler command failed"); process.exit(1); }