#7362·express

res.send(ArrayBuffer) silently sends {} as JSON

Author: myselfsiddharthCreated Jul 6, 2026Updated Sep 12, 2026

Bug

res.send() handles Buffer and TypedArray (ArrayBuffer.isView) as binary data, but a raw ArrayBuffer — the standard JavaScript binary data type — falls through to this.json(chunk), producing {}withContent-Type: application/json`.

res.send(new ArrayBuffer(10))
// Sends: {} (Content-Type: application/json)
// Expected: 10 zero bytes (Content-Type: application/octet-stream)

Cause

PR #6285 (merged as 55869f49) fixed Uint8Array/DataView support by adding an ArrayBuffer.isView() check. However, ArrayBuffer.isView(new ArrayBuffer(...)) returns false, so raw ArrayBuffer was missed.

Proposed fix

Add an instanceof ArrayBuffer check in lib/response.js that converts to Buffer and sets the binary content type, consistent with the existing ArrayBuffer.isView branch.

Real-world impact

ArrayBuffer is the standard binary type used by fetch, Web Crypto, WebSocket, FileReader, and similar APIs. Passing it directly to res.send() is a common scenario that currently fails silently.