socketio / socketio/socket.io

React native ios crashes on production with extraHeaders

Open
#5,120 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation package:socket.io-client
Dominant language
TypeScript
Stars
63.2k
Forks
10.3k
Avg merge
11d 20h
Merged PRs (30d)
2

Description

I need to pass a cookie, for the ingress session affinity, in order to maintain connection in multi pods,
so i set the extraHeaders:

when running the app in debug (in simulator or device) it works as expected, but after releasing ios app in testflight and testing, it crashes,

 Fatal Exception: NSInvalidArgumentException
-[__NSArrayM length]: unrecognized selector sent to instance 0x283dcfde0

To Reproduce

Socket.IO server version: 4.4.0

Server

const io = new Socket(server, {
    transports: ['websocket', 'polling'],
    cors: {
      origin: '*',
      methods: ['GET', 'POST'],
      credentials: true,
    },
    adapter: redisAdapter({
      pubClient: redisClient,
      subClient: redisClient.duplicate(),
    }),
  });

Socket.IO client version: 4.7.2

Client

initSocket(userId, cookie) {
    this.socket = io(SOCKET_URL, {
      query: `userId=${userId}`,
      autoConnect: false,
      transport: ['polling', 'websocket'],
      extraHeaders: {
        'Cookie': cookie,
      },
    });
  }
 

Expected behavior
Connect without crash and maintain connection

Platform:

  • Device: iphone 11
  • OS: ios 17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start at the initSocket entry point and reproduce the provided extraHeaders configuration in an iOS production or TestFlight build, then inspect the NSInvalidArgumentException path. Done means the app connects without crashing on iOS 17 while retaining the requested session-affinity behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, javascript, react-native
Domain
mobile, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.