Skip to content

Release HTTP context after WebSocket upgrade

Choose a tag to compare

@github-actions github-actions released this 06 Sep 06:46
· 2 commits to main since this release

Socket now releases the HTTP request and AdonisJS context after a WebSocket upgrade completes.

Breaking changes

socket.raw.request and socket.raw.httpContext have been removed.

The HTTP context remains available during upgrade middleware, origin validation, and authentication. Channel middleware and handlers should use:

  • socket.user for durable authenticated identity
  • socket.raw.data for connection-lifetime state

If a channel needs data from the upgrade request, extract only that data during authentication and return it as part of the authenticated user value.

Memory usage

In our benchmark with 10,000 connections, releasing the HTTP object graph reduced median server memory by:

  • 38.8 MiB of used heap
  • 41.9 MiB of RSS
  • approximately 4.1 kB of heap per connection
  • 39.7 MiB of peak RSS during mass reconnection

External memory, heartbeat cost, broadcast cost, and reconnection time did not show a meaningful change.

The benchmark uses three independent runs with forced garbage collection and a separate process for WebSocket clients.