Repository navigation
Read http.request options at run time, speak HTTP over Unix sockets, and fill the boot path's net and fetch gaps - #1515
Merged
Merged
Conversation
…and fill the boot path's net and fetch gaps
http.request, https.request and get now accept options the compiler
cannot see as an object literal: a RequestOptions variable, a literal
that spreads one, or a literal that sets socketPath. The runtime reads
the record in the ClientRequest constructor's order with Node's errors;
documented options it does not implement throw the runtime fence when
they carry a value. https adds rejectUnauthorized, ca and servername.
socketPath dials a Unix domain socket in the net unit; the agent keys
its sockets by the path as Node's getName does, and the Host header
defaults to localhost. server.listen(path[, cb]) binds a Unix socket and
removes the socket file when the server closes; a numeric string is
still a port. Errors name the path ("connect ENOENT /path", "listen
EADDRINUSE: address already in use /path"). Windows reports ENOTSUP.
A TypeScript object literal with no contextual type that spreads a
checked-dynamic value maps to the checked dynamic, so
`const options = { ...location, path, timeout }` compiles.
A socket's 'lookup' event reaches its listeners with (err, address,
family, host) for each address a host name resolves to, or once with
the lookup error, before 'connect'. Only programs that listen for
'lookup' install the lookup records; elsewhere the hook sites are a NULL
check.
server.close((err) => ...) runs the callback with undefined at 'close',
or with ERR_SERVER_NOT_RUNNING when the server was not listening; a
server that never listened now emits 'close'. IncomingMessage 'data'
listeners may take string chunks after setEncoding, and res.end()
accepts a string-or-undefined chunk.
fetch's BodyInit and HeadersInit unions, as RequestInit-derived option
types spell them under @types/node, map to the checked dynamic, and a
URLSearchParams body is sent form-encoded, as by Node.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Node answers a Unix-socket server's address() with its path. Programs that call listen() with a string argument now get a Unix-aware address(): typed `string | AddressInfo | null` (the @types/node declaration), it answers the path; typed as the AddressInfo record alone, which cannot hold the path, it throws for such a server, as does the composed address().port read. Every other program keeps the record-only lowering, so their output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…socket closes - http.request, https.request and get validate each name and value of a flat [name, value, ...] headers array, as Node's _storeHeader does: a name that is not an HTTP token throws ERR_INVALID_HTTP_TOKEN, a value with an invalid character throws ERR_INVALID_CHAR, and an odd length throws ERR_INVALID_ARG_VALUE with the inspected array. The [[name, value], ...] entry form throws the options fence. - A closing socket drops its 'lookup' listeners with its other listeners, so a listener that holds the socket no longer keeps it alive. - The options-record diagnostics snapshot no longer expects the socketPath refusal.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Read http.request options at run time, speak HTTP over Unix sockets, and fill the boot path's net and fetch gaps
Builds on #1429 (merged), which gives
http.RequestOptionschecked-dynamic storage.Summary
Request options read at run time.
http.request,https.requestandgetnow accept options the compiler cannot see as an object literal:RequestOptionsvariable;socketPath.The runtime reads that record the way Node's
ClientRequestconstructor does, in the same order and with the same errors. It covers:agent, the path's unescaped-character check, andprotocol;defaultPortandport, where a string port such as a URL's.portworks;hostname/hostandtimeout;method, validated and then upper-cased;maxHeaderSize;headers: an object with string or number values, arrays as repeated lines, or the flat array form;signal.Documented options the runtime does not implement (
auth,createConnection,family,lookup,localAddressand others, plussetHost: false) throw a runtime fence error when they hold a value, instead of being silently ignored. Undocumented keys are ignored, as Node ignores them.httpsaddsrejectUnauthorized,caandservername.Unix domain sockets.
socketPathdials a Unix socket from the net unit.getNamedoes, and the Host header defaults tolocalhost.server.listen(path[, callback])binds a Unix socket and removes the socket file when the server closes, like libuv.isPipeName).connect ENOENT /path,listen EADDRINUSE: address already in use /path.ENOTSUP.server.address()on a Unix-socket server returns the socket path, as in Node, when its result is typedstring | AddressInfo | null(the @types/node declaration). Where the result is typed as theAddressInforecord alone, which cannot hold the path, it throws for such a server. Only programs that calllisten()with a string argument get this Unix-awareaddress(), so every other program compiles exactly as before.A TypeScript object literal with no contextual type that spreads a checked-dynamic value now maps to the checked dynamic too, so
const options = { ...location, path, method, headers, timeout, signal }compiles.Socket
'lookup'. A socket's'lookup'listeners get(err, address, family, host)for each address a host name resolves to, or once with the lookup error, before'connect'. Only programs that register a'lookup'listener install the lookup records, from their C main. In every other program the hook sites are a NULL check.Smaller http fixes.
server.close((err) => ...)runs the callback withundefinedat'close', or withERR_SERVER_NOT_RUNNINGwhen the server was not listening.'close'. Before, its close callbacks never ran.IncomingMessage'data'listeners may take string chunks aftersetEncoding.res.end()accepts astring | undefinedchunk.fetch init members. Under @types/node, fetch's
BodyInitandHeadersInitunions now map to the checked dynamic. So doOmit/Pick/Partialof a checked-dynamic stdlib interface such asRequestInit. Option types derived fromRequestInittherefore compile.A
URLSearchParamsbody is now sent form-encoded, as Node sends it. It used to be sent as the text[object Object].Evidence
Each program runs under Node and as a native binary, and the outputs must match byte for byte. All pass in both lanes.
6440-http-socket-path: an HTTP server on a Unix socket.socketPath, aRequestOptionsvariable, a spread literal, andhttp.get.6441-http-request-options-record:RequestOptionschosen at run time (TCP with a string port, or a socket path), spread into an unannotated options object;agent: falseand an aborted signal;6442-https-request-options-record:httpswith runtime options over TCP and over a Unix socket. It covers the CA, an unverifiable certificate with and withoutrejectUnauthorized, and the protocol check.6443-net-lookup-http-close-text:'lookup'for a host name, and none for an IP address;'data'listeners aftersetEncodingon both sides;res.end(string | undefined);tests/fixtures/node-types/http-socket-path.ts: a cell-API-style client typed by @types/node, plusclose((err) => ...)with and withoutERR_SERVER_NOT_RUNNING.tests/fixtures/node-types/fetch-init-members.ts: an options interface extendingOmit<RequestInit, ...>, destructured and passed back into fetch. It sends string,URLSearchParamsand Buffer bodies and record, array andHeadersheaders, and carries the remaining members as anOmit<...>.scr_http_request_agent_ex,scr_net_dispatchandscr_fetch_static, which grow by about 1.3 KB of text in an http program. File sizes grow by up to +1.9% because the data segment moves to the next page. Bench geomean is -0.55% and self-compile +1.32%, both within tolerance.test:ts7 --baselines-onlyrecords 6 new baselines and changes none. The docs gate passes.🤖 Generated with Claude Code