Skip to content

maxHttpBufferSize violation silently disconnects client with no error event #706

@yujiang

Description

@yujiang

Summary

When a client sends a message that exceeds the maxHttpBufferSize, the server closes the connection immediately with no way for the developer to detect or handle the error properly.

Expected Behavior

There should be a proper 'error' event (e.g., 'error', 'packetError', or 'close' with a specific reason), or a packet with error metadata that allows distinguishing "oversized payload" from a general transport error.

Actual Behavior

  • Server does NOT trigger socket.on('big-message')
  • socket.conn.on('error') is NOT called
  • Only socket.on('disconnect') is called with reason 'transport error'
  • No detailed error message available

Why this matters

This makes it impossible to distinguish between an oversized payload vs. a broken connection, which causes:

  • Inaccurate logging / monitoring
  • Inability to handle abuse cases
  • Poor developer experience when debugging

Minimal Repro

// Server (Node.js)
const io = new Server(server, {
  maxHttpBufferSize: 1e6
});
io.on('connection', (socket) => {
  socket.on('big-message', (data) => {
    console.log('Received:', data.length);
  });
  socket.on('disconnect', (reason) => {
    console.log('Disconnected:', reason);
  });
});

// Client (Browser or Node)
const socket = io('http://localhost:3000', { reconnection: false });
const big = 'x'.repeat(2 * 1024 * 1024); // 2MB
socket.emit('big-message', big);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions