Nock compatibility
- [ ] should be safe to call in the middle of a request
- [x] socket emits
connectandsecureConnectevents @kettanaito (edge case - https://github.com/mswjs/interceptors/pull/515#issuecomment-2067702330) - [ ] Request with
Expect: 100-continuetriggers continue event (https://github.com/mswjs/interceptors/pull/599) @mikicho - [x] Fetch: follow redirect responses #626
Transfer Encoding @mikicho
support transfer-encoding: chunked
https://github.com/mswjs/interceptors/pull/596
- [x] should pass filteringPath options
- [x] should pass filteringRequestBody options
- [x] match body with form multipart
- [x] records and replays objects correctly
- [x] records and replays correctly with filteringRequestBody
- [x] records and replays gzipped nocks correctly
- [x] records and replays the response body
preemtive timeout
We decided to remove this feature from Nock. It not relevant for fetch.
We should consider if/how we want to support this for httpClient. this is a nice feature.
- [x] emits a timeout - with setTimeout
- [x] emits a timeout - with options.timeout
- [x] emits a timeout - with Agent.timeout
- [x] emits a timeout - options.timeout takes precedence over Agent.timeout
Headers
- [x] folds duplicate headers the same as Node
- [x] when keys are duplicated, is evaluated once per input field name, in correct order
Recorder
- [ ] does not record requests from previous sessions
- [x] logs recorded objects
Thanks for putting this down, @mikicho! Let's split these between ourselves and finish the interceptor. Please, if you are working on a task, put your GitHub handle next to it so I'd know, and I will do the same.
As usual, we can start with adding a test for the thing, verifying if it's not passing already, and then opening pull requests to #515. Does that sound good to you?
socket emits connect and secureConnect
This should already be the case:
- Original requests: https://github.com/mswjs/interceptors/pull/515/files#diff-94fc27cca818a0da8d402e251763d5dbf450d62c3cde37ceef7ea8494a324ddeR210-R214
- Mocked requests: https://github.com/mswjs/interceptors/pull/515/files#diff-94fc27cca818a0da8d402e251763d5dbf450d62c3cde37ceef7ea8494a324ddeR375-R380
Not sure if we have tests for this, may be indirectly tested and still missing test cases just for the connect and secureConnect events.
Edit: I'm assigning this to myself, will ensure those events are emitted correctly.
Added implementation for following redirect responses in fetch: #627.
should be safe to call in the middle of a request
@mikicho, can you elaborate on this scenario, please? Nock itself works by patching http.get and friends, so the interceptor is applied before any requests happen. I think I'm just misunderstanding what "to call" refers to here, to be honest.
Do you mean a scenario like this?
http.get()
interceptor.on('request', ({ controller }) => controller.respondWith(new Response()))
This is more of a nock-side issue, which I don't think we should tackle on the interceptors side.
The gist is that nock used to be sync (which is incompatible with how Node) and it was safe to call reset in the middle of a request. Currently, I have just dropped "support" for it and I'm waiting to see if anyone complains
I lack enough familiarity with Nock to say this for certain, but applying/removing mocking in a middle of a request sounds like a bad idea. Imo, the request must be handled according to the interception state at the time of being issued.
I'm closing this issue for now, and we will address the remaining points as separate individual issues when they are prioritized.