Skip to content

fix(types): include the data attribute on the connect_error event - #5544

Closed
lazerg wants to merge 2 commits into
socketio:mainfrom
lazerg:fix/issue-5542-connect-error-data-type
Closed

lazerg wants to merge 2 commits into
socketio:mainfrom
lazerg:fix/issue-5542-connect-error-data-type

Conversation

@lazerg

@lazerg lazerg commented Aug 24, 2026

Copy link
Copy Markdown

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

connect_error is typed as plain Error, even though the client always attaches a data property to it (forwarded from the err.data set on the server-side middleware error). Accessing err.data from a listener is a type error unless you cast it yourself.

New behavior

connect_error is now typed as Error & { data?: any }, matching the ExtendedError shape already used on the server side. The internal @ts-ignore needed to attach .data in onpacket() is gone too, since the variable is properly typed.

Other information (e.g. related issues)

Fixes #5542

@darrachequesne

Copy link
Copy Markdown
Member

Closing this PR since #5548 has been merged and supersedes these changes. Thanks!

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.

PacketType.CONNECT_ERROR adds err.data but downstream interface SocketReservedEventsMap does not expect that

2 participants