Skip to content

TypeError: strMessage.trim is not a function, ws problem? #57

@WarlockD

Description

@WarlockD

(node:59108) UnhandledPromiseRejectionWarning: TypeError: strMessage.trim is not a function at BidirectionalWebsocketRouter._routeMessage (H:\StationneerDev\DiscordBot\node_modules\jsonrpc-bidirectional\src\BidirectionalWebsocketRouter.js:167:18)
Took me a while to trace this down. WebSocket returns not a string but a Buffer Object you can check out the code for it here
https://github.com/websockets/ws/blob/master/lib/buffer-util.js

I did a quick hack of`

strMessage = `${strMessage}`;

just to get my crappy project done.

As a side note I hate HATE this bug. I run in to ".trim is not a function" all the time and would of expected ws to guarantee string text messages:P

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