Skip to content

fix(docs): add explicit cleanup hooks for playground timeouts#222

Open
legend4tech wants to merge 1 commit into
StellarFlow-Network:mainfrom
legend4tech:fix/issue-155-memory-leak-playground-tabs
Open

fix(docs): add explicit cleanup hooks for playground timeouts#222
legend4tech wants to merge 1 commit into
StellarFlow-Network:mainfrom
legend4tech:fix/issue-155-memory-leak-playground-tabs

Conversation

@legend4tech
Copy link
Copy Markdown
Contributor

Fixes #155: Memory Leak Prevention on Interactive Playground Tabs

Description

This PR resolves a memory leak issue and prevents "unmounted component" state update errors within the Developer Gateway & Docs (src/app/docs/page.tsx). Previously, repeatedly switching between documentation tabs or navigating away from the page while the handleCopy or handleTestInvoke timers were still running resulted in an accumulation of unmanaged listeners (timeouts).

Technical Changes

  • Explicit Cleanup Hooks: Added an explicit useEffect cleanup hook that destroys any active timers when the module unmounts, severing pending context subscriptions.
  • Reference Tracking: Utilized useRef (copyTimeoutRef and invokeTimeoutRef) to accurately track and maintain the background timers without triggering unnecessary re-renders.
  • Deduplication: Added checks to immediately sever any currently running timeouts if a user rapidly spams the interaction buttons before triggering a new timeout.

Verification

  • Rapidly switching between the Rust/JS tabs while an action is processing no longer causes overlapping UI bugs.
  • Navigating away from the /docs route while an RPC invocation is processing no longer throws React state update warnings in the console.

closes #155

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@legend4tech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🧹 Perf | Memory Leak Prevention on Interactive Playground Tabs

1 participant