Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-taxis-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

output more wrangler command logs when the command fails
10 changes: 8 additions & 2 deletions packages/cloudflare/src/cli/utils/run-wrangler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
[
Expand All @@ -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.<wrangler env>` while we should load `.env.<process.env.NEXTJS_ENV>`
// See https://opennext.js.org/cloudflare/howtos/env-vars
Expand All @@ -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);
}
Expand Down
Loading