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: socket null in logger #3422

Merged

Conversation

codeflyer
Copy link
Contributor

Adds a check on the existence of the request socket before accessing the attributes, in a previous commit was missed a check.

It should fix #3419

Checklist

Suites:   96 passed, 96 of 96 completed
Asserts:  5498 passed, 2 skip, of 5500
Time:     31s
-------------------|---------|----------|---------|---------|-------------------
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 |                   
  ...TypeParser.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 |                   
  ...Validation.js |     100 |      100 |     100 |     100 |                   
  logger.js        |     100 |      100 |     100 |     100 |                   
  ...inOverride.js |     100 |      100 |     100 |     100 |                   
  pluginUtils.js   |     100 |      100 |     100 |     100 |                   
  reply.js         |     100 |      100 |     100 |     100 |                   
  ...GenFactory.js |     100 |      100 |     100 |     100 |                   
  request.js       |     100 |      100 |     100 |     100 |                   
  route.js         |     100 |      100 |     100 |     100 |                   
  ...-compilers.js |     100 |      100 |     100 |     100 |                   
  ...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 |                   
-------------------|---------|----------|---------|---------|-------------------
[fix-3419-logger-fail-on-null-socket 0165c12] fix: socket null in logger
 2 files changed, 21 insertions(+), 1 deletion(-)
➜  fastify git:(fix-3419-logger-fail-on-null-socket) npm run benchmark

> fastify@3.23.0 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 3.73s
[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 │ 11 ms │ 12 ms │ 1.45 ms │ 3.52 ms │ 142.66 ms │
[1] └─────────┴──────┴──────┴───────┴───────┴─────────┴─────────┴───────────┘
[1] ┌───────────┬────────┬────────┬───────┬─────────┬─────────┬─────────┬────────┐
[1] │ Stat      │ 1%     │ 2.5%   │ 50%   │ 97.5%   │ Avg     │ Stdev   │ Min    │
[1] ├───────────┼────────┼────────┼───────┼─────────┼─────────┼─────────┼────────┤
[1] │ Req/Sec   │ 43327  │ 43327  │ 69439 │ 73151   │ 64702.4 │ 8615.71 │ 43305  │
[1] ├───────────┼────────┼────────┼───────┼─────────┼─────────┼─────────┼────────┤
[1] │ Bytes/Sec │ 8.1 MB │ 8.1 MB │ 13 MB │ 13.7 MB │ 12.1 MB │ 1.61 MB │ 8.1 MB │
[1] └───────────┴────────┴────────┴───────┴─────────┴─────────┴─────────┴────────┘
[1] 
[1] Req/Bytes counts sampled once per second.
[1] 
[1] 1941k requests in 30.09s, 363 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

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. Good initiative

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

@mcollina mcollina merged commit 692fe4f into fastify:main Nov 7, 2021
@github-actions
Copy link

github-actions bot commented Nov 8, 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 8, 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