Skip to content

fastify websockets breaking change #553

@bhamon

Description

@bhamon

A breaking change has been added to @fastify/websockets@10 (fastify/fastify-websocket#289). It breaks the fastify integration.

The wsHandler first parameter type is now WebSocket rather than a NodeJS stream.
To create a stream from it an explicit call to ws.createWebSocketStream(socket) is required.

A dirty patch to make it work with the new version:

    wsHandler: (socket, req) => {
      const connection = ws.createWebSocketStream(socket);
      connection.socket = socket;
      return wsHandler.call(_app, connection, req);
    }

I'm concerned about how to properly propagate errors for the newly created stream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleasedHas been released and published

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions