Skip to content

types(client): add and export ExtendedError for connect_error event - #5548

Merged
darrachequesne merged 2 commits into
socketio:mainfrom
bhumin18:fix/client-connect-error-type
Sep 10, 2026
Merged

darrachequesne merged 2 commits into
socketio:mainfrom
bhumin18:fix/client-connect-error-type

Conversation

@bhumin18

@bhumin18 bhumin18 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds and exports the ExtendedError interface in socket.io-client and updates SocketReservedEvents to type connect_error: (err: ExtendedError) => void.

Motivation

When a connection middleware rejects the connection with extra metadata, the client receives PacketType.CONNECT_ERROR and sets err.data = packet.data.data. Previously, connect_error was typed as standard Error, which required TypeScript users to write (err as any).data.

This change mirrors the server package's ExtendedError declaration, enables type-safe access to err.data, and removes the need for // @ts-ignore in onpacket.

Fixes #5542

Checklist

  • TypeScript builds successfully (npm run compile --workspace=socket.io-client)
  • Code matches Prettier style (npm run format:check --workspace=socket.io-client)
  • Unit tests and type tests added and passing

@bhumin18

Copy link
Copy Markdown
Contributor Author

Hi @darrachequesne, just checking in to see if any additional tests or changes are needed for this PR whenever you have a moment to review. Thanks!

@darrachequesne
darrachequesne merged commit c0d5450 into socketio:main Sep 10, 2026
@darrachequesne

Copy link
Copy Markdown
Member

@bhumin18 nice, 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