-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing socket #255
base: master
Are you sure you want to change the base?
Parsing socket #255
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
> [email protected] 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
> [email protected] 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -14,7 +14,7 @@ declare namespace inject { | |||
|
|||
export type DispatchFunc = http.RequestListener | |||
|
|||
export type CallbackFunc = (err: Error, response: Response) => void | |||
export type CallbackFunc = (err: Error | undefined, response: Response | undefined) => void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a dedicated PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.equal(err instanceof inject.errors.ContentLength, true) | ||
t.error(res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test says can override stream payload content-length header
- are we blocking this feature now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -806,14 +831,14 @@ test('simulates split', (t) => { | |||
}) | |||
}) | |||
|
|||
test('simulates error', (t) => { | |||
t.skip('simulates error', (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.skip('simulates error', (t) => { | |
test('simulates error', (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 test
andnpm run benchmark
and the Code of conduct