Skip to content
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

fix: verify request socket before access attributes #3420

Merged

Conversation

codeflyer
Copy link
Contributor

@codeflyer codeflyer commented Nov 4, 2021

Adds a check on the existence of the request socket before accessing the attributes.

It should fix #3419

Checklist

Suites:   96 passed, 96 of 96 completed
Asserts:  5497 passed, 2 skip, of 5499
Time:     28s
-----------------------------|---------|----------|---------|---------|-------------------
File                         | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-----------------------------|---------|----------|---------|---------|-------------------
All files                    |     100 |      100 |     100 |     100 |                   
 fastify                     |     100 |      100 |     100 |     100 |                   
  fastify.js                 |     100 |      100 |     100 |     100 |                   
 fastify/lib                 |     100 |      100 |     100 |     100 |                   
  contentTypeParser.js       |     100 |      100 |     100 |     100 |                   
  context.js                 |     100 |      100 |     100 |     100 |                   
  decorate.js                |     100 |      100 |     100 |     100 |                   
  errors.js                  |     100 |      100 |     100 |     100 |                   
  fourOhFour.js              |     100 |      100 |     100 |     100 |                   
  handleRequest.js           |     100 |      100 |     100 |     100 |                   
  headRoute.js               |     100 |      100 |     100 |     100 |                   
  hooks.js                   |     100 |      100 |     100 |     100 |                   
  initialConfigValidation.js |     100 |      100 |     100 |     100 |                   
  logger.js                  |     100 |      100 |     100 |     100 |                   
  pluginOverride.js          |     100 |      100 |     100 |     100 |                   
  pluginUtils.js             |     100 |      100 |     100 |     100 |                   
  reply.js                   |     100 |      100 |     100 |     100 |                   
  reqIdGenFactory.js         |     100 |      100 |     100 |     100 |                   
  request.js                 |     100 |      100 |     100 |     100 |                   
  route.js                   |     100 |      100 |     100 |     100 |                   
  schema-compilers.js        |     100 |      100 |     100 |     100 |                   
  schema-controller.js       |     100 |      100 |     100 |     100 |                   
  schemas.js                 |     100 |      100 |     100 |     100 |                   
  server.js                  |     100 |      100 |     100 |     100 |                   
  symbols.js                 |     100 |      100 |     100 |     100 |                   
  validation.js              |     100 |      100 |     100 |     100 |                   
  warnings.js                |     100 |      100 |     100 |     100 |                   
  wrapThenable.js            |     100 |      100 |     100 |     100 |                   
-----------------------------|---------|----------|---------|---------|-------------------

 npm run benchmark

> fastify@3.22.1 benchmark /Users/davide/Work/nearForm/bench/fastify
> npx concurrently -k -s first "node ./examples/benchmark/simple.js" "npx autocannon -c 100 -d 30 -p 10 localhost:3000/"

npx: installed 27 in 4.023s
[1] Running 30s test @ http://localhost:3000/
[1] 100 connections with 10 pipelining factor
[1] 
[1] ┌─────────┬──────┬──────┬───────┬───────┬─────────┬────────┬───────────┐
[1] │ Stat    │ 2.5% │ 50%  │ 97.5% │ 99%   │ Avg     │ Stdev  │ Max       │
[1] ├─────────┼──────┼──────┼───────┼───────┼─────────┼────────┼───────────┤
[1] │ Latency │ 0 ms │ 0 ms │ 10 ms │ 11 ms │ 1.49 ms │ 3.7 ms │ 224.03 ms │
[1] └─────────┴──────┴──────┴───────┴───────┴─────────┴────────┴───────────┘
[1] ┌───────────┬─────────┬─────────┬─────────┬─────────┬─────────┬────────┬─────────┐
[1] │ Stat      │ 1%      │ 2.5%    │ 50%     │ 97.5%   │ Avg     │ Stdev  │ Min     │
[1] ├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼────────┼─────────┤
[1] │ Req/Sec   │ 35359   │ 35359   │ 65599   │ 71423   │ 63308.8 │ 8538.6 │ 35351   │
[1] ├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼────────┼─────────┤
[1] │ Bytes/Sec │ 6.61 MB │ 6.61 MB │ 12.3 MB │ 13.4 MB │ 11.8 MB │ 1.6 MB │ 6.61 MB │
[1] └───────────┴─────────┴─────────┴─────────┴─────────┴─────────┴────────┴─────────┘
[1] 
[1] Req/Bytes counts sampled once per second.
[1] 
[1] 1899k requests in 30.08s, 355 MB read
[1] npx autocannon -c 100 -d 30 -p 10 localhost:3000/ exited with code 0
--> Sending SIGTERM to other processes..
[0] node ./examples/benchmark/simple.js exited with code SIGTERM

@codeflyer codeflyer changed the title fix: verify request socket before access attributes (#3491) fix: verify request socket before access attributes Nov 4, 2021
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@zekth zekth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina mcollina merged commit d72dfa0 into fastify:main Nov 4, 2021
@github-actions
Copy link

github-actions bot commented Nov 5, 2022

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The server crashes if the socket is undefined and try to access attributes
3 participants