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/every-dolls-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Fix: make sure that remote proxy sessions's logs can be silenced when the wrangler log level is set to "none"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import remoteBindingsWorkerPath from "worker:remoteBindings/ProxyServerWorker";
import { logger } from "../../logger";
import { getBasePath } from "../../paths";
import { startWorker } from "../startDevWorker";
import type { LoggerLevel } from "../../logger";
import type { StartDevWorkerInput, Worker } from "../startDevWorker";
import type { Config } from "@cloudflare/workers-utils";
import type { RemoteProxyConnectionString } from "miniflare";
Expand Down Expand Up @@ -45,11 +46,7 @@ export async function startRemoteProxySession(
port: await getPort(),
},
inspector: false,
logLevel:
// If the logger has a logLevel of "debug" it means that the user is likely trying to debug some issue,
// so we should respect that here as well for the remote proxy session. In any other case, to avoid noisy
// logs, we just simply fall back to "error"
logger.loggerLevel === "debug" ? "debug" : "error",
logLevel: getStartWorkerLogLevel(logger.loggerLevel),
},
bindings: rawBindings,
}).catch((startWorkerError) => {
Expand Down Expand Up @@ -114,3 +111,27 @@ export type RemoteProxySession = Pick<Worker, "ready" | "dispose"> & {
updateBindings: (bindings: StartDevWorkerInput["bindings"]) => Promise<void>;
remoteProxyConnectionString: RemoteProxyConnectionString;
};

/**
* Gets the log level to use for the remote worker.
*
* @param wranglerLogLevel The log level set for the Wrangler process.
* @returns The log level to use for the remove worker.
*/
function getStartWorkerLogLevel(wranglerLogLevel: LoggerLevel): LoggerLevel {
switch (wranglerLogLevel) {
case "debug":
// If the `logLevel` is "debug" it means that the user is likely trying to debug some issue,
// so we should respect that here as well for the remote proxy session.
return "debug";

case "none":
// If the `logLevel` is "none" it means that the user is trying to silence all output,
// so we should respect that here as well for the remote proxy session.
return "none";

default:
// In any other case we want to default to "error" to avoid noisy logs
return "error";
}
}
Loading