Draft
Conversation
4 tasks
4 tasks
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.
net.connection#707netsocket level #741secureConnectmsw#2569Changes
SocketInterceptorthat intercepts the outgoing socket packets on thenet.connect()/tls.connect()levels. The interception mostly works via a "server-side socket" instance and patching TCPWrap/TLSWrap JavaScript bindings for C++ network code (socket._handle) to pend the connection until the interceptor decides what to do with it.HttpRequestInterceptorto replaceClientRequestInterceptor.getRawRequestutility has been removed. Use theinitiatorreference directly./utils/nodeandgetClientRequestBodyStreamhas been removed. Use theinitiatorreference directly.Features
CONNECTrequests (fixes Support "CONNECT" requests (in proxies) #481, closes feat(wip): support "CONNECT" request #621).fetchandrequesteven when they aren't global.initiatoron the "request" event listener. Theinitiatorproperty points toClientRequest,XMLHttpRequest, orRequestinstance that initiated the intercepted request. If no instance can be reliably deduced, points to the rawnet.Socketbehind the connection.keylogevent on the socket.OPTIONSpreflight request based on the JSDOM implementation (previously, preflight triggered for requests that shouldn't trigger it).Bug fixes
http/https(e.g.import * as httpbroke previously since we cannot patch that).Content-Typeheader added by Undici was not set on mocked responses.request.uploadwasn't dispatched correctly.totalresponse body length is now computed only from thecontent-lengthmocked response header, just like it's done natively.progressevent is now correctly emitted on the request for chunked responses.Todos
SocketInterceptor. Cover behaviors like socket re-usage, event emission, properties (especially on TLS sockets), etc._tlsErroremissionsessionevent shouldn't be emitted for reused sessions. Mocks always emit it now.options.sessionshould be respected. Afaik, if provided, that is a pointer to a previously active session.CONNECTrequests (see Support "CONNECT" requests (in proxies) #481 / feat(wip): support "CONNECT" request #621). Might they be supported now?SocketInterceptorcan run at the same time without conflicting.TypeError: Second argument must be a buffer. Reproduce:pnpm run test:node test/modules/httpmultiple times in a row. Flaky.req.end()in the socket'sconnectevent.fetch(Undici fetch) in theHttpRequestInterceptor(currently times out).fetchworks. Our test server has an expired certificate andfetchdoesn't provide the means to setrejectUnauthorized: falseso requests fail.HttpRequestInterceptorneeds to have the response decompression and redirect following logic. It likely doesn't. Just wonder how we can implementFetchInterceptoron top of it then.initiatorproperty on therequestevent.httpXMLHttpRequestfetchgetRawRequestinitiator. Refactor whatsetRawRequestdid before.HttpRequestInterceptornow intercepts everything and more specialized interceptors only provide theinitiatorvia async context. In the browser, however, the/injectversion of the interceptors has to be used instead.controller.errorWith()because it's more semantically valid to usesocket.destroy(). It provides no additional functionality and is a 1-to-1 replacement.applyPatch: UseSymbol.for()instead ofSymbol()to account for isolated environments (e.g. browser extensions (see there are problems while multiple browser extension use new XMLHttpRequestInterceptor() #771)./node.tsversion (more powerful).llhttpthe same way Undici uses it. That's the most performant and reliable way of introducing a parser to the stack.