Skip to content

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

Open
@sbougon

Description

@sbougon

Hello,

love your library, thank you !

I developed a CLI using mockttp, but every so often, I see the following on my program stdout:
Error: read ECONNRESET at TCP.onStreamRead (node:internal/stream_base_commons:217:20) at TCP.callbackTrampoline (node:internal/async_hooks:130:17) { errno: -54, code: 'ECONNRESET', syscall: 'read' }

Turns out it's because an error is thrown (correctly and can be handled by my code (using server.on('abort',...)) but because the code in https://github.com/httptoolkit/mockttp/blob/main/src/rules/websockets/websocket-handlers.ts#L395 calls console.warn(e), I can't do anything to provide a clean output to my program. The only way would be to hot-patch console.warn, but I don't want to do this.

In my case, I'm proxying an Android app which repeatedly tries to see if a debugging tools will accept a connection. When there is not debugging tool present, the socket errors out (✅) but a console.warn() gets printed (❌).

Would you be willing to accept a PR which remove the console.warn() ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions