Socket.io-client fires "connect" event but can't send events to server
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 63.2k
- Forks
- 10.3k
- Avg merge
- 11d 20h
- Merged PRs (30d)
- 2
Description
Describe the bug
If I leave my site domain and use the browser back button to return socket.io-client fires the "connect" event, but the client socket can't send any events to the server until the connection is disconnected and then reconnects or I refresh the page.
To Reproduce
Please fill the following code example:
Socket.IO server version: 4.5.4
Socket.IO client version: 4.5.4
Link to repl: https://replit.com/@ambil/socket-io-bug-example#index.js
- Click "Open website" to run code fiddle in a new browser tab
- Click the "Test Event" button. You'll see a new message appended to the list with each click that says: "event: button_clicked"
- In the same browser tab, navigate to a new domain (ex: google.com)
- Use the browser back button to navigate back to the previous tab
- Without refreshing the page, click the "Test Event" button. Notice a new message is not appended to the list, although the status shows "Connected"
Expected behavior
Since the client is firing off the "connect" event, I'd expect the server to acknowledge client events right away.
Platform:
- Chrome for MacOS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Replit reproduction in index.js and reproduce the browser back-button sequence in Chrome on macOS. Trace the client connection state after the connect event and verify the Test Event button can send button_clicked without a page refresh, forced disconnect, or reconnect.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- frontend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100