Skip to content

Fix rowTransaction memory retention while preserving pre-mount transaction buffering#456

Draft
Copilot wants to merge 12 commits intov35from
copilot/fix-memory-leak-rowtransaction
Draft

Fix rowTransaction memory retention while preserving pre-mount transaction buffering#456
Copilot wants to merge 12 commits intov35from
copilot/fix-memory-leak-rowtransaction

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 22, 2026

rowTransaction updates were causing memory growth because transaction payloads were retained longer than necessary.
This update keeps the original pre-mount buffering behavior (needed before the lazy grid fragment is ready) while preventing stale references from accumulating.

  • Root cause

    • Wrapper-level buffering existed to queue transactions before grid mount, but previous changes removed that path entirely.
    • The fix needed to preserve pre-mount queuing while ensuring buffered data is released after handoff.
    • Follow-up review identified that duplicate transaction payloads could be queued repeatedly during pre-mount accumulation.
  • Changes

    • Reintroduced wrapper buffering in src/lib/components/AgGrid.react.js for transactions received before JS grid mount.
    • Added mount handoff/cleanup so buffered transactions are cleared once the fragment mounts.
    • Updated src/lib/fragments/AgGrid.react.js to initialize replay state from buffered parent transactions and replay them safely.
    • Fixed queued replay invocation to avoid incorrect callback argument forwarding during forEach.
    • Ensured internal props used for buffering/mount signaling are excluded from AG Grid prop conversion.
    • Added de-duplication in queue accumulation (wrapper and fragment paths) so equivalent rowTransaction payloads are not buffered multiple times before mount.
    • Centralized queued replay behavior to avoid duplicate transaction application during grid initialization when props.rowTransaction and buffered state are both present.
    • Added/expanded regression coverage in tests/test_selection_persistence.py:
      • test_sp002_row_transaction_before_grid_ready validates queued transaction replay, existing row integrity, and rowTransaction reset to null after replay,
      • test_sp003_duplicate_row_transaction_before_grid_ready validates duplicate pre-mount transaction payloads are buffered/applied only once.
    • Merged latest v35 into this branch to resolve conflicts and added an unreleased changelog entry in CHANGELOG.md.
  • Net effect

    • Preserves expected behavior when rowTransaction arrives before grid readiness.
    • Prevents unbounded retention of transaction references after mount.
    • Avoids duplicate buffering of equivalent pre-mount transactions.
    • Avoids duplicate application during mount-time replay.
    • Keeps transaction replay behavior correct and verifiable.

Copilot AI linked an issue Apr 22, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix memory leak when using rowTransaction Prevent rowTransaction reference retention in the React wrapper Apr 22, 2026
Copilot AI requested a review from BSd3v April 22, 2026 18:49
@BSd3v
Copy link
Copy Markdown
Collaborator

BSd3v commented Apr 22, 2026

@copilot

The reason this existed previously was in the event that the grid wasnt mounted, the rowTransactions would build until it was mounted and could be loaded. We need to make sure that this case still works.

@BSd3v
Copy link
Copy Markdown
Collaborator

BSd3v commented Apr 23, 2026

@copilot

see above

Copy link
Copy Markdown
Author

Copilot AI commented Apr 23, 2026

@copilot

The reason this existed previously was in the event that the grid wasnt mounted, the rowTransactions would build until it was mounted and could be loaded. We need to make sure that this c...

Implemented and pushed a fix that preserves pre-mount rowTransaction buffering while still preventing retention leaks. The wrapper now buffers transactions only until the JS grid fragment mounts, then clears the wrapper queue; the fragment hydrates/replays buffered transactions on mount. I also fixed queued replay so it applies transactions with the correct API argument and added regression coverage in test_sp002_row_transaction_before_grid_ready. Commit: e8c7200 (plus test assertion follow-up 651c960). Screenshot: https://github.com/user-attachments/assets/b480af1f-4410-4533-8576-4da10fbfa0c9

@copilot

see above

Addressed in the latest commits: pre-mount transaction buffering is restored and replayed after mount, and the replay path bug for queued transactions is fixed. Commit: e8c7200 (test follow-up 651c960). Screenshot: https://github.com/user-attachments/assets/b480af1f-4410-4533-8576-4da10fbfa0c9

Copilot AI changed the title Prevent rowTransaction reference retention in the React wrapper Fix rowTransaction memory retention while preserving pre-mount transaction buffering Apr 23, 2026
@BSd3v
Copy link
Copy Markdown
Collaborator

BSd3v commented Apr 23, 2026

@copilot

Fix conflicts and also add a changelog entry. Also, we need to make sure that the arr1 is not already in arr2, I guess we could do a useEffect on the props for rowTransaction.

Copilot AI and others added 3 commits April 23, 2026 11:01
…k-rowtransaction

# Conflicts:
#	src/lib/fragments/AgGrid.react.js

Co-authored-by: BSd3v <82055130+BSd3v@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Apr 23, 2026

@copilot

Fix conflicts and also add a changelog entry. Also, we need to make sure that the arr1 is not already in arr2, I guess we could do a useEffect on the props for rowTransaction.

Done. I merged origin/v35 and resolved the branch conflicts, added the changelog entry in CHANGELOG.md under unreleased fixed items, and updated queueing so duplicate rowTransaction payloads are not re-buffered by value while still using the existing useEffect on props.rowTransaction for pre-mount accumulation. Commits: 0fccc98 (conflict resolution/changelog merge context) and fde08a0 (dedupe logic). Screenshot: https://github.com/user-attachments/assets/9bb30433-c65b-4068-a11a-5692a8297d4b

@BSd3v
Copy link
Copy Markdown
Collaborator

BSd3v commented Apr 23, 2026

@copilot

Add a test for the memory leak

Copy link
Copy Markdown
Author

Copilot AI commented Apr 23, 2026

@copilot

Add a test for the memory leak

Added a memory-leak regression check in test_sp002_row_transaction_before_grid_ready that verifies queued pre-mount rowTransaction is released (null) after replay, so stale transaction payloads are not retained. Commits: 80865ca (test) and 67cf962 (callback naming cleanup). Screenshot: https://github.com/user-attachments/assets/9bb30433-c65b-4068-a11a-5692a8297d4b

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes rowTransaction pre-mount buffering/replay to prevent memory growth from retained transaction payloads, while preserving expected behavior when transactions arrive before the lazy-loaded grid fragment is available.

Changes:

  • Reintroduces wrapper-level buffering for pre-mount rowTransaction and adds mount handoff/cleanup.
  • Initializes fragment-side replay state from buffered parent transactions, adds de-duplication, and fixes replay invocation to avoid incorrect callback argument forwarding.
  • Adds a regression test for pre-mount rowTransaction behavior and includes an unreleased changelog entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/lib/components/AgGrid.react.js Buffers rowTransaction before fragment mount, de-dupes queued payloads, and clears buffered state on fragment mount signal.
src/lib/fragments/AgGrid.react.js Seeds queued transaction state from wrapper, replays safely, omits internal props from conversion, and adds mount signaling propTypes.
tests/test_selection_persistence.py Adds regression test ensuring pre-mount transaction is applied and rowTransaction resets to null.
CHANGELOG.md Adds unreleased “Fixed” entry documenting the buffering/replay + retention fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/fragments/AgGrid.react.js
Comment thread src/lib/components/AgGrid.react.js
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.

Issue: memory leak when using rowTransaction

3 participants