1

I am using SSE connection workflow in one of my projects. I store SSE response objects in the local memory which can then be used to notify the client. SSE connections/response are stored in following format. memory = {"transctionId": [array of subscribers]} each transactionId can have multiple subscribers. The idea is when some event has happened to a given transaction i notify all the subscribers.

At some point i would need to cleanup my memory object to prevent memory leak. Currently i am using subscriber.writable property to check if a given transaction has no active subscribers and can be deleted from memory. However, I see that writable property is always true even if stream is destroyed/closed by the client and memory is never cleared.

I need a way to delete transactionId from the memory when i can no longer write to any of the subscribers. Can i use subscriber.destroyed? Suppose destroyed is true are we sure that such a stream can never be used again and safe to delete? Or client reconnection respawns same stream?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.