Skip to content

WebSocketClient channels do not expose full error payload #31

@prodderman

Description

@prodderman

Hi,

It appears that when a channel receives an error, the error object passed to listeners does not include the full payload returned by the server.

Setup:

const client = new DXLinkWebSocketClient({})
client.setAuthToken('token')
client.connect('url')
const channel = client.openChannel('SERVICE', {})
channel.addErrorListener((error) => console.log(error))

// send invalid message
channel.addStateChangeListener((state) => {
      if (state === DXLinkChannelState.OPENED) {
        channel.send({
          type: 'MESSAGE_TYPE',
          channel: channel.id,
          invalidField: 'invalid'
     })
  }
})

Observed behavior:

The error received in the listener is:

{ "type": "INVALID_MESSAGE", "message": "Some text" }

Expected behavior:

The full error payload returned by the server should be exposed to the listener, for example:

{
  "type": "ERROR",
  "channel": 1,
  "error": "INVALID_MESSAGE",
  "message": "Some text",
  "correlationId": "228"
}

The additional fields are important for proper error handling.
Thanks!

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