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

Ping/pong for SSE #2150

Merged
merged 2 commits into from Dec 26, 2022
Merged

Ping/pong for SSE #2150

merged 2 commits into from Dec 26, 2022

Conversation

ardatan
Copy link
Collaborator

@ardatan ardatan commented Nov 22, 2022

Closes #2095

@changeset-bot
Copy link

changeset-bot bot commented Nov 22, 2022

🦋 Changeset detected

Latest commit: a926e97

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
graphql-yoga Minor
@graphql-yoga/common Patch
@graphql-yoga/node Patch
@graphql-yoga/render-graphiql Major
@graphql-yoga/plugin-apollo-inline-trace Major
@graphql-yoga/plugin-apq Major
@graphql-yoga/plugin-defer-stream Major
@graphql-yoga/plugin-disable-introspection Major
@graphql-yoga/plugin-persisted-operations Major
@graphql-yoga/plugin-prometheus Major
@graphql-yoga/plugin-response-cache Major
@graphql-yoga/plugin-sofa Major
apollo-federation-gateway-with-yoga Patch
apollo-subgraph-with-yoga Patch
graphql-lambda Patch
cloudflare-advanced Patch
cloudflare Patch
hackernews Patch
hello-world-benchmark Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Nov 22, 2022

🚀 Snapshot Release (alpha)

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

Package Version Info
@graphql-yoga/common 3.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
graphql-yoga 3.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
@graphql-yoga/node 3.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apollo-inline-trace 1.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apq 1.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-defer-stream 1.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-disable-introspection 0.1.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-persisted-operations 1.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-prometheus 1.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-response-cache 1.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-sofa 1.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎
@graphql-yoga/render-graphiql 3.2.0-alpha-20221226105640-ddc717ce npm ↗︎ unpkg ↗︎

@github-actions
Copy link
Contributor

github-actions bot commented Nov 22, 2022

✅ Benchmark Results

     ✓ no_errors
     ✓ expected_result

     checks.........................: 100.00% ✓ 196934      ✗ 0    
     data_received..................: 28 MB   922 kB/s
     data_sent......................: 11 MB   377 kB/s
     http_req_blocked...............: avg=1.19µs   min=800ns    med=1µs      max=5.11ms   p(90)=1.4µs    p(95)=1.6µs   
     http_req_connecting............: avg=1ns      min=0s       med=0s       max=111.69µs p(90)=0s       p(95)=0s      
   ✓ http_req_duration..............: avg=235.6µs  min=170.99µs med=212.09µs max=18.18ms  p(90)=251.39µs p(95)=286.89µs
       { expected_response:true }...: avg=235.6µs  min=170.99µs med=212.09µs max=18.18ms  p(90)=251.39µs p(95)=286.89µs
     http_req_failed................: 0.00%   ✓ 0           ✗ 98467
     http_req_receiving.............: avg=17.47µs  min=10.1µs   med=15.3µs   max=4.54ms   p(90)=20.4µs   p(95)=23µs    
     http_req_sending...............: avg=5.47µs   min=3.9µs    med=4.59µs   max=4.99ms   p(90)=6µs      p(95)=7.19µs  
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=212.65µs min=149.89µs med=192.79µs max=18.09ms  p(90)=224.8µs  p(95)=255.79µs
     http_reqs......................: 98467   3282.080742/s
     iteration_duration.............: avg=299.74µs min=220.29µs med=270.99µs max=18.62ms  p(90)=323.59µs p(95)=365.59µs
     iterations.....................: 98467   3282.080742/s
     vus............................: 1       min=1         max=1  
     vus_max........................: 1       min=1         max=1  

@github-actions
Copy link
Contributor

github-actions bot commented Nov 22, 2022

🚀 Website Preview

The latest changes to the website are available as preview in: https://6d94281b.graphql-yoga.pages.dev

Co-authored-by: Denis Badurina <badurinadenis@gmail.com>
@ardatan ardatan merged commit 290c7f7 into main Dec 26, 2022
@ardatan ardatan deleted the sse-interval branch December 26, 2022 11:48
@keonik
Copy link
Contributor

keonik commented Jan 5, 2023

Thank you for this ❤️

Comment on lines +30 to +36
pingInterval = setInterval(() => {
if (!controller.desiredSize) {
clearInterval(pingInterval)
return
}
controller.enqueue(textEncoder.encode(':\n\n'))
}, timeoutInSeconds * 1000) as unknown as number
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be based on the last emitted value instead? 12 seconds since the last message got sent to the client?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm makes sense to me. Let's do that.

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.

SSE keep alive ping
4 participants