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(sse): prevent onClosed from firing twice in EventStream #704

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

joshmossas
Copy link
Contributor

@joshmossas joshmossas commented Mar 13, 2024

Fixes issue where onClosed always fires twice when using Server Sent Events.

The following changes were made to fix the issue:

  • remove redundant event.node.res.on('close') hook in onClosed method

The following changes were made to related documentation:

  • Remove redundant eventStream.close() invocation from ./examples/server-sent-events.ts
  • Remove redundant eventStream.close() invocation from ./docs/1.guide/6.websockets.md
  • Remove redundant eventStream.close() invocation from ./tests/sse.test.ts

eventStream.close() doesn't need to be called in onClosed by default because it is automatically handled when autoclose is set to true

πŸ”— Linked issue

Fixes #703

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 79.73%. Comparing base (a58d7c9) to head (4fb9e71).
Report is 64 commits behind head on main.

Files Patch % Lines
examples/server-sent-events.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #704      +/-   ##
==========================================
+ Coverage   77.83%   79.73%   +1.89%     
==========================================
  Files          47       53       +6     
  Lines        4286     5294    +1008     
  Branches      611      674      +63     
==========================================
+ Hits         3336     4221     +885     
- Misses        933     1055     +122     
- Partials       17       18       +1     

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@pi0 pi0 changed the title [fix] prevent onClosed from firing twice in EventStream fix(sse): prevent onClosed from firing twice in EventStream Apr 17, 2024
@pi0 pi0 marked this pull request as draft April 17, 2024 14:10
@joshmossas joshmossas marked this pull request as ready for review April 18, 2024 03:28
@joshmossas joshmossas marked this pull request as draft April 18, 2024 03:29
@joshmossas
Copy link
Contributor Author

@pi0 Just curious what was the reason you marked this PR as a draft. I just wanted to check and see if I needed to change something on my end.

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.

onClosed fires twice in server sent events
1 participant