Conversation
|
It takes some time to optimize |
212bbbd to
5f0b4b2
Compare
light-my-request on parsing-socket [!+⇕] is 📦 v5.10.0 via v20.5.0 on ☁️ (us-west-2) took 5s
❯ npm run benchmark
> light-my-request@5.10.0 benchmark
> node benchmark/benchmark.js
Request x 160,977 ops/sec ±3.86% (80 runs sampled)
Custom Request x 14,371 ops/sec ±4.12% (81 runs sampled)
Request With Cookies x 136,650 ops/sec ±1.94% (87 runs sampled)
Request With Cookies n payload x 134,341 ops/sec ±2.71% (81 runs sampled)
ParseUrl x 1,207,543 ops/sec ±1.39% (87 runs sampled)
ParseUrl and query x 114,550 ops/sec ±2.00% (90 runs sampled)light-my-request on master [!⇕] is 📦 v5.10.0 via v20.5.0 on ☁️ (us-west-2) took 11s
❯ npm run benchmark
> light-my-request@5.10.0 benchmark
> node benchmark/benchmark.js
Request x 267,087 ops/sec ±14.67% (72 runs sampled)
Custom Request x 21,130 ops/sec ±3.09% (85 runs sampled)
Request With Cookies x 203,067 ops/sec ±7.45% (74 runs sampled)
Request With Cookies n payload x 205,931 ops/sec ±2.17% (83 runs sampled)
ParseUrl x 1,168,402 ops/sec ±5.19% (80 runs sampled)
ParseUrl and query x 141,309 ops/sec ±2.21% (94 runs sampled) |
mcollina
left a comment
There was a problem hiding this comment.
There seems to be quite a significant performance regression with this PR.
I think it's due to the addition of the internal Socket, so I think this might be a no-go.
I wouldn't also claim bun support without the tests running on Bun too.
Eomm
left a comment
There was a problem hiding this comment.
It is hard to find the old code and the new code feature.
I looked at the commits to follow the step-by-step process, but 2 commits did not help.
I really suggest splitting this PR into smaller pieces
| export type DispatchFunc = http.RequestListener | ||
|
|
||
| export type CallbackFunc = (err: Error, response: Response) => void | ||
| export type CallbackFunc = (err: Error | undefined, response: Response | undefined) => void |
| t.equal(err instanceof inject.errors.ContentLength, true) | ||
| t.error(res) |
There was a problem hiding this comment.
The test says can override stream payload content-length header - are we blocking this feature now?
There was a problem hiding this comment.
Yes
- it is not supported with test example http.Server/http.request
- I can't call the Dispatch function unless I read everything from Readable
| }) | ||
|
|
||
| test('simulates error', (t) => { | ||
| t.skip('simulates error', (t) => { |
There was a problem hiding this comment.
| t.skip('simulates error', (t) => { | |
| test('simulates error', (t) => { |
There was a problem hiding this comment.
This was done on purpose as it could not be reproduced with a real server and request
maybe you have ideas how to do it?
|
|
||
| const errorMessage = 'The dispatch function has already been invoked' | ||
|
|
||
| class Chain { |
There was a problem hiding this comment.
This refactor could be another PR - smaller PRs helps to get the code merged faster
|
I don't think we agreed to #252, this PR seems a bit premature too. |
Yes, so I made a another PR with planning for the long future |
|
This PR will simply allow it to be more native, with support for most events and most attribute, methods that's why I used extends Socket and IncomingMessage |
migrate to class syntax (Chain, request, response)
add a mock socket class (parse headers, body, trailers)
change emitting and subscription
this is the sequel to #252
bun.js support
update usage of deprecated attribute
some test was changed due to unexpected behavior
the main tests were tested with
Checklist
npm run testandnpm run benchmarkand the Code of conduct