MatthewWid / better-sse

⬆ Dead simple, dependency-less, spec-compliant server-sent events implementation for Node, written in TypeScript.
https://matthewwid.github.io/better-sse/
MIT License
558 stars 14 forks source link

isConnected should be set on response closed and prevent pushing data #57

Closed agix closed 9 months ago

agix commented 9 months ago

Response can also close without request emitting the close event.

both should be listened to set the isConnected boolean to false.

Also, pushing data should throw on a disconnected session.

MatthewWid commented 9 months ago

Benchmarks look fine.

Before:

Benchmarking "Push events with channels".
better-sse x 45,644 ops/sec ±4.66% (85 runs sampled)

After:

Benchmarking "Push events with channels".
better-sse x 45,425.8 ops/sec ±5.66% (82 runs sampled)
agix commented 9 months ago

Thx for the review !

MatthewWid commented 9 months ago

These changes are now published in v0.11.0.