Skip to content

node:http: Agent/ClientRequest/IncomingMessage/ServerResponse not constructable via new #4904

Description

@proggeramlug

Summary

Node exposes http.Agent, http.ClientRequest, http.IncomingMessage, and http.ServerResponse as constructable classes. Under Perry, new-ing them throws TypeError: <X> is not a constructor. (new https.Agent() with no args works today via the curated fixture, but new http.Agent({options}), new ClientRequest(...), new IncomingMessage(...), and new ServerResponse(...) do not.)

Repro shapes

const http = require('http');
new http.Agent({ keepAlive: true });          // test-http-agent-keepalive.js
new http.ClientRequest({ createConnection: () => {} });  // test-http-client-defaults.js
new http.IncomingMessage(socket);             // test-http-incoming-matchKnownFields.js
new http.ServerResponse({ /* req */ });       // test-http-server-response-standalone.js

These constructors are part of Node's public surface (used directly by tests and by some userland libs that subclass them). They need real construct semantics (the instance must carry the expected fields/methods), not just a callable export.

Failing tests (13)

test-http-agent-abort-controller.js
test-http-agent-error-on-idle.js
test-http-agent-keepalive-delay.js
test-http-agent-keepalive.js
test-http-agent-timeout-option.js
test-http-client-defaults.js
test-http-client-set-timeout-after-end.js
test-http-client-timeout-option-with-agent.js
test-http-incoming-matchKnownFields.js
test-http-incoming-message-connection-setter.js
test-http-incoming-message-destroy.js
test-http-outgoing-message-write-callback.js
test-http-server-response-standalone.js

Acceptance

new http.Agent(opts), new http.ClientRequest(opts), new http.IncomingMessage(socket), new http.ServerResponse(req) construct working instances. The 13 tests reach their assertions.


Part of #2132. Measured via scripts/node_core_subset.py --api http https vs pinned Node v22 corpus.

Activity

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

    bugConfirmed defect or regressionparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions