Kolibri Core Communication - Implement Request Timeouts for Mediator
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
This project aims to enhance the reliability of cross-window communication by implementing request timeouts within the
Mediator class.
Details:
Currently, the sendMessageAwaitReply method in the Mediator class returns a Promise and registers a listener that remains active until a response is received. If the remote window (e.g., an iframe or parent window) crashes, navigates away, or fails to respond, the Promise remains "pending" indefinitely.
- What is this feature? It adds an optional
timeoutparameter tosendMessageAwaitReplyand logic to reject the promise if the time limit is exceeded. - What problem is it solving? It prevents memory leaks caused by "zombie" callbacks staying in the
__messageHandlersobject and prevents the UI from hanging while waiting for a response that will never come. - Why are we doing this now? As the communication layer grows more complex, ensuring robust memory management and error handling is critical for application stability.
goals
- Who is this feature for? Developers working with the
postMessagelayer in Kolibri who need reliable request-response patterns.
How do we know this feature is successful? Requests that do not receive a response within the allotted time correctly reject with a Timeout Error, and the associated message handler is verified to be removed from memory.
User Stories or Requirements
- Requirement 1:
Add an optional timeout argument to sendMessageAwaitReply (defaulting to a sensible value like 5-10 seconds).
Requirement 2: Use setTimeout to trigger a rejection if the response does not arrive.
Requirement 3: Ensure clearTimeout is called if the message arrives successfully to prevent memory overhead.
Requirement 4: Ensure the removeMessageHandler cleanup logic is executed in both success and timeout scenarios.
@rtibbles
@rtibbles assign me this issue I will add this new feature
Season's greetings! 👋
We'd like to thank everyone for another year of fruitful collaborations, engaging discussions, and for the continued support of our work. Learning Equality will be on holidays from December 22 to January 5. We look forward to much more in the new year and wish you a very happy holiday season!
Are you preparing for Google Summer of Code? See our GSoC guidelines.
There is not a clear motivation for adding this - please don't have an LLM write issues just so you can try to be assigned to them, it doesn't help anyone.