MatthewWid / better-sse

⬆ Dead simple, dependency-less, spec-compliant server-sent events implementation for Node, written in TypeScript.
MIT License
485 stars 14 forks source link

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

Closed agix closed 7 months ago

agix commented 7 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 7 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 7 months ago

Thx for the review !

MatthewWid commented 7 months ago

These changes are now published in v0.11.0.