oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.44k stars 2.7k forks source link

Socket.io socket.handshake.address sometimes contains undefined #9842

Open SupertigerDev opened 6 months ago

SupertigerDev commented 6 months ago

What version of Bun is running?

1.1.18

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

import express from 'express';
import { createServer } from 'http';
import { Server } from "socket.io";

const app = express();
const server = createServer(app);
const io = new Server(server, {transports: ["websocket"]});

app.get('/', (req, res) => {
  res.send(`
  <script src="https://cdn.socket.io/4.7.5/socket.io.min.js"></script>
  <script>
  const socket = io("http://localhost:3000", {
    transports: ["websocket"]
  });
  </script>
  `);
});

io.on('connection', (socket) => {
  console.log("connected", socket.handshake.address)
});

server.listen(3000, () => {
  console.log('listening on http://localhost:3000');
});
  1. bun i express socket.io
  2. Paste the code above
  3. go to http://localhost:3000
  4. Keep refreshing the page and look in console

What is the expected behavior?

It should consistantly log connected ::1 just like it does in nodejs

What do you see instead?

image

I see that it sometimes logs undefined

Additional information

It may be a Windows only issue, not sure.

SupertigerDev commented 2 months ago

Just want to confirm that this issue is still happening on version 1.1.18