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(server): add waitUntil to the server context in Fastify integration #1926

Merged
merged 2 commits into from
Dec 24, 2024

Conversation

ardatan
Copy link
Owner

@ardatan ardatan commented Dec 24, 2024

While calling handleNodeRequest or handleNodeRequestAndResponse, waitUntil is not added automatically as in requestListener for Node.js integration.
This change adds waitUntil into the serverContext if not present.

Fixes the issue with Fastify integration that uses the mentioned methods

@ardatan ardatan requested a review from dotansimha December 24, 2024 14:41
Copy link
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@whatwg-node/server 0.9.65-alpha-20241224144308-cda07d199da2a29f42043448a40e85b64d51d8a4 npm ↗︎ unpkg ↗︎

Copy link
Contributor

@benchmarks/node-fetch results (consumeBody)

   ✓ active_handles.................: avg=141.062 min=92      med=141     max=197      p(90)=159     p(95)=165    
     data_received..................: 21 MB  712 kB/s
     data_sent......................: 14 MB  457 kB/s
     http_req_blocked...............: avg=6.19µs  min=661ns   med=1.34µs  max=12.6ms   p(90)=2.07µs  p(95)=2.35µs 
     http_req_connecting............: avg=4.29µs  min=0s      med=0s      max=12.4ms   p(90)=0s      p(95)=0s     
     http_req_duration..............: avg=21.4ms  min=4.71ms  med=20.78ms max=533.14ms p(90)=26.7ms  p(95)=29.69ms
       { expected_response:true }...: avg=21.4ms  min=4.71ms  med=20.78ms max=533.14ms p(90)=26.7ms  p(95)=29.69ms
     http_req_failed................: 0.00%  ✓ 0           ✗ 139650
     http_req_receiving.............: avg=34.66µs min=9.48µs  med=24.44µs max=13.65ms  p(90)=38.82µs p(95)=45.64µs
     http_req_sending...............: avg=11.86µs min=3.5µs   med=6.4µs   max=10.23ms  p(90)=9.96µs  p(95)=13.82µs
     http_req_tls_handshaking.......: avg=0s      min=0s      med=0s      max=0s       p(90)=0s      p(95)=0s     
     http_req_waiting...............: avg=21.35ms min=4.62ms  med=20.74ms max=533.07ms p(90)=26.65ms p(95)=29.59ms
     http_reqs......................: 139650 4654.497188/s
     iteration_duration.............: avg=42.92ms min=20.68ms med=41.31ms max=570.32ms p(90)=49.24ms p(95)=54.55ms
     iterations.....................: 69806  2326.615329/s
     vus............................: 100    min=100       max=100 
     vus_max........................: 100    min=100       max=100 

Copy link
Contributor

@benchmarks/node-fetch results (noConsumeBody)

   ✓ active_handles.................: avg=139.522482 min=12      med=139     max=191    p(90)=162     p(95)=166    
     data_received..................: 22 MB  744 kB/s
     data_sent......................: 15 MB  482 kB/s
     http_req_blocked...............: avg=3.68µs     min=621ns   med=1.43µs  max=7.46ms p(90)=2.07µs  p(95)=2.42µs 
     http_req_connecting............: avg=1.72µs     min=0s      med=0s      max=7.42ms p(90)=0s      p(95)=0s     
     http_req_duration..............: avg=20.48ms    min=3.33ms  med=19.78ms max=1.11s  p(90)=25.78ms p(95)=27.59ms
       { expected_response:true }...: avg=20.48ms    min=3.33ms  med=19.78ms max=1.11s  p(90)=25.78ms p(95)=27.59ms
     http_req_failed................: 0.00%  ✓ 0           ✗ 145879
     http_req_receiving.............: avg=35.02µs    min=9.17µs  med=24.07µs max=20.5ms p(90)=39.34µs p(95)=46.7µs 
     http_req_sending...............: avg=12.99µs    min=3.42µs  med=6.85µs  max=20ms   p(90)=10.18µs p(95)=15.03µs
     http_req_tls_handshaking.......: avg=0s         min=0s      med=0s      max=0s     p(90)=0s      p(95)=0s     
     http_req_waiting...............: avg=20.43ms    min=3.28ms  med=19.74ms max=1.11s  p(90)=25.74ms p(95)=27.52ms
     http_reqs......................: 145879 4862.006355/s
     iteration_duration.............: avg=41.09ms    min=10.02ms med=39.66ms max=1.13s  p(90)=45.02ms p(95)=50.68ms
     iterations.....................: 72925  2430.519907/s
     vus............................: 10     min=10        max=100 
     vus_max........................: 100    min=100       max=100 

Copy link
Contributor

@benchmarks/server results (native)

     ✓ no-errors
     ✓ expected-result

   ✓ checks.........................: 100.00% ✓ 209280      ✗ 0     
     data_received..................: 21 MB   701 kB/s
     data_sent......................: 8.4 MB  279 kB/s
     http_req_blocked...............: avg=1.38µs   min=872ns    med=1.17µs   max=260.62µs p(90)=1.88µs   p(95)=2.04µs  
     http_req_connecting............: avg=1ns      min=0s       med=0s       max=119.51µs p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=223.94µs min=171.92µs med=212.9µs  max=8.15ms   p(90)=241.31µs p(95)=251.75µs
       { expected_response:true }...: avg=223.94µs min=171.92µs med=212.9µs  max=8.15ms   p(90)=241.31µs p(95)=251.75µs
     http_req_failed................: 0.00%   ✓ 0           ✗ 104640
     http_req_receiving.............: avg=25.36µs  min=13.19µs  med=23.64µs  max=3.07ms   p(90)=30.81µs  p(95)=33.54µs 
     http_req_sending...............: avg=6.33µs   min=4.15µs   med=5.51µs   max=291.51µs p(90)=8.17µs   p(95)=8.83µs  
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=192.25µs min=146.98µs med=181.22µs max=8.06ms   p(90)=206.24µs p(95)=216.29µs
     http_reqs......................: 104640  3487.876618/s
     iteration_duration.............: avg=282.21µs min=217.28µs med=270.48µs max=8.28ms   p(90)=302.07µs p(95)=315µs   
     iterations.....................: 104640  3487.876618/s
     vus............................: 1       min=1         max=1   
     vus_max........................: 1       min=1         max=1   

Copy link
Contributor

@benchmarks/server results (undici)

     ✓ no-errors
     ✓ expected-result

   ✓ checks.........................: 100.00% ✓ 219442      ✗ 0     
     data_received..................: 22 MB   735 kB/s
     data_sent......................: 8.8 MB  293 kB/s
     http_req_blocked...............: avg=1.4µs    min=902ns    med=1.2µs    max=174.29µs p(90)=1.88µs   p(95)=2.04µs  
     http_req_connecting............: avg=1ns      min=0s       med=0s       max=116.02µs p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=210.31µs min=156.88µs med=198.92µs max=47.69ms  p(90)=224.64µs p(95)=233.85µs
       { expected_response:true }...: avg=210.31µs min=156.88µs med=198.92µs max=47.69ms  p(90)=224.64µs p(95)=233.85µs
     http_req_failed................: 0.00%   ✓ 0           ✗ 109721
     http_req_receiving.............: avg=25.32µs  min=14.18µs  med=23.55µs  max=2.44ms   p(90)=30.49µs  p(95)=33.37µs 
     http_req_sending...............: avg=6.36µs   min=4.14µs   med=5.55µs   max=555.14µs p(90)=8.16µs   p(95)=8.86µs  
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=178.62µs min=129.68µs med=166.92µs max=47.61ms  p(90)=189.95µs p(95)=198.3µs 
     http_reqs......................: 109721  3657.242221/s
     iteration_duration.............: avg=268.9µs  min=204.61µs med=256.38µs max=47.84ms  p(90)=285.72µs p(95)=297.25µs
     iterations.....................: 109721  3657.242221/s
     vus............................: 1       min=1         max=1   
     vus_max........................: 1       min=1         max=1   

Copy link
Contributor

@benchmarks/server results (ponyfill)

     ✓ no-errors
     ✓ expected-result

   ✓ checks.........................: 100.00% ✓ 296422      ✗ 0     
     data_received..................: 29 MB   973 kB/s
     data_sent......................: 12 MB   395 kB/s
     http_req_blocked...............: avg=1.32µs   min=832ns    med=1.12µs   max=286.97µs p(90)=1.79µs   p(95)=1.96µs  
     http_req_connecting............: avg=1ns      min=0s       med=0s       max=148.23µs p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=141.08µs min=98.48µs  med=136.33µs max=7.16ms   p(90)=158.57µs p(95)=165.57µs
       { expected_response:true }...: avg=141.08µs min=98.48µs  med=136.33µs max=7.16ms   p(90)=158.57µs p(95)=165.57µs
     http_req_failed................: 0.00%   ✓ 0           ✗ 148211
     http_req_receiving.............: avg=24.6µs   min=10.92µs  med=23.15µs  max=5.74ms   p(90)=30.27µs  p(95)=33.04µs 
     http_req_sending...............: avg=6.19µs   min=4.03µs   med=5.32µs   max=681.41µs p(90)=7.97µs   p(95)=8.6µs   
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=110.28µs min=70.87µs  med=105.14µs max=7.08ms   p(90)=124.46µs p(95)=130.23µs
     http_reqs......................: 148211  4940.026488/s
     iteration_duration.............: avg=198.02µs min=141.88µs med=192.44µs max=7.35ms   p(90)=218.18µs p(95)=227.14µs
     iterations.....................: 148211  4940.026488/s
     vus............................: 1       min=1         max=1   
     vus_max........................: 1       min=1         max=1   

@ardatan ardatan merged commit bae5de1 into master Dec 24, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants