Skip to content

πŸ› Bug Report β€” Runtime APIs: node:http ServerResponse sends the status text unknown when the app sets no status messageΒ #8737

Done

Description

@JPeer264

A node:http server behind httpServerHandler answers with the status text unknown when the app sets no status message. Node.js answers with the standard text of the status code OK for 200. Since workerd tries to be as close as possible to Node I'll assume that this is actually a bug. The repro and cause has been AI generated, but I verified it manually.

Reproduction

wrangler dev index.mjs --compatibility-date 2026-04-26 --compatibility-flags nodejs_compat

import { httpServerHandler } from 'cloudflare:node';
import { createServer } from 'node:http';

createServer((req, res) => {
  res.on('finish', () => {
    console.log(JSON.stringify({ statusCode: res.statusCode, statusMessage: res.statusMessage }));
  });
  res.end('ok');
}).listen(8080);

export default httpServerHandler({ port: 8080 });
$ curl -s -i http://localhost:8787/ | head -1
HTTP/1.1 200 unknown

# wrangler output
{"statusCode":200,"statusMessage":"unknown"}
[wrangler:info] GET / 200 unknown (137ms)

Cause

ServerResponse starts with a truthy default (internal_http_server.ts#L441):

statusMessage = 'unknown';

writeHead keeps it, because ||= only assigns when the value is falsy (#L721):

this.statusMessage ||= STATUS_CODES[`${statusCode}`] || 'unknown';

In Node.js, statusMessage starts as undefined, so writeHead sets STATUS_CODES[statusCode].

Expected behavior

HTTP/1.1 200 OK, and res.statusMessage === 'OK' after the headers are sent, as in Node.js.

Versions

wrangler 4.165.0 (workerd 1.20261118.1).

Activity

  1. added 2 commits that reference this issue on Nov 21, 2026
    b8effe1
    26ab325
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions