Skip to content

Commit

Permalink
only proxy consoleAPICalled events in remote mode
Browse files Browse the repository at this point in the history
  • Loading branch information
RamIdeas committed Nov 8, 2023
1 parent fc983ad commit a49cc8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/wrangler/src/api/startDevWorker/ProxyController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,19 @@ export class ProxyController extends EventEmitter {
this.latestConfig = data.config;
this.latestBundle = data.bundle;

const proxyData = {
proxyLogsToController: data.config.dev?.remote, // in local mode, workerd logs to terminal directly
...data.proxyData,
};

void this.sendMessageToProxyWorker({
type: "play",
proxyData: data.proxyData,
proxyData,
});

void this.sendMessageToInspectorProxyWorker({
type: "reloadComplete",
proxyData: data.proxyData,
proxyData,
});
}
onProxyWorkerMessage(message: ProxyWorkerOutgoingRequestBody) {
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/src/api/startDevWorker/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,5 @@ export type ProxyData = {
userWorkerInnerUrlOverrides: Partial<UrlOriginParts>;
headers: Record<string, string>;
liveReload?: boolean;
proxyLogsToController?: boolean;
};
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,11 @@ export class InspectorProxyWorker implements DurableObject {
| DevToolsEvents;
this.sendDebugLog("RUNTIME INCOMING MESSAGE", msg);

if (isDevToolsEvent(msg, "Runtime.exceptionThrown")) {
this.sendProxyControllerMessage(event.data);
}
if (
isDevToolsEvent(msg, "Runtime.exceptionThrown") ||
this.proxyData?.proxyLogsToController &&
isDevToolsEvent(msg, "Runtime.consoleAPICalled")
) {
this.sendProxyControllerMessage(event.data);
Expand Down

0 comments on commit a49cc8a

Please sign in to comment.