Skip to content

Add a logUpstreamErrors passthrough option - #217

Open
theluckystrike wants to merge 1 commit into
httptoolkit:mainfrom
theluckystrike:feat/148-log-upstream-errors
Open

theluckystrike wants to merge 1 commit into
httptoolkit:mainfrom
theluckystrike:feat/148-log-upstream-errors

Conversation

@theluckystrike

Copy link
Copy Markdown
Contributor

Fixes #148

This adds the logUpstreamErrors option you suggested on #148, defaulting to true. Set to false on a passthrough rule, it stops the console output for upstream failures, which are often expected in test runs. Leaving it unset changes nothing.

server.forAnyWebSocket().thenPassThrough({
    logUpstreamErrors: false
});

The WebSocket passthrough is where the noise comes from, so that's where the gating is. In websocket-step-impls.ts it covers pipeWebSocket, mirrorRejection and the upstream request handlers in the step itself. The option lives on the shared passthrough connection options, so request passthrough rules accept and serialize it too, but that path doesn't print upstream connection errors today and its behaviour is unchanged. Both steps serialize the option and default it to true when deserializing, so remote rules work the same way.

Two new tests in test/integration/websockets.spec.ts trigger an upstream WebSocket failure through the proxy and capture the console. With the option off nothing is logged, and with the default the error still is. With the gating taken out of the build, the first test fails on the Error in proxied WebSocket line. The full websockets spec passes (34 tests).

Michael

…t errors

Defaults to true. When false, the WebSocket passthrough skips its console
output for upstream failures (pipeWebSocket, mirrorRejection and the
upstream request handlers). Request passthrough accepts and serializes the
same shared option.

Fixes httptoolkit#148

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

console.warn() in websocket-handlers.js is poluting the stdout

1 participant