graphql-sse: Cannot call write after a stream was destroyed
Screenshot
Expected Behaviour Do not write to the stream after it is closed / destroyed
Actual Behaviour Writes to stream after it was destroyed which results in an error.
Debug Information
This bug resulted when using the use/express
handler created with a createHandler
call. According to the code there is no check in place wether the stream was closed in the meantime.
Further Information
Maybe introduce a variable let cancelled = false;
and set it to true once the stream was closed. Check for cancelled
before trying to do a .write()
.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (12 by maintainers)
Commits related to this issue
- fix(use/http,use/http2,use/express,use/fastify): Handle cases where response's `close` event is late (#75) Closes #69 — committed to enisdenjo/graphql-sse by enisdenjo 10 months ago
- chore(release): 🎉 2.2.2 [skip ci] ## [2.2.2](https://github.com/enisdenjo/graphql-sse/compare/v2.2.1...v2.2.2) (2023-08-22) ### Bug Fixes * **use/http,use/http2,use/express,use/fastify:** Handle c... — committed to enisdenjo/graphql-sse by semantic-release-bot 10 months ago
- fix(use/http,use/http2,use/express,use/fastify): Check `writable` instead of `closed` before writing to response Closes #69 — committed to enisdenjo/graphql-sse by enisdenjo 10 months ago
- chore(release): 🎉 2.2.3 [skip ci] ## [2.2.3](https://github.com/enisdenjo/graphql-sse/compare/v2.2.2...v2.2.3) (2023-08-23) ### Bug Fixes * **use/http,use/http2,use/express,use/fastify:** Check `w... — committed to enisdenjo/graphql-sse by semantic-release-bot 10 months ago
@michelalbers, @groundmuffin the v2.2.2 includes a fix, would be great if you can test it out and report if the issue persists. Thank you for reporting and advising!