Add regression test for resultEqualityCheck receiving a cleared WeakRef - #763
Open
veksa wants to merge 1 commit into
Open
Add regression test for resultEqualityCheck receiving a cleared WeakRef#763veksa wants to merge 1 commit into
resultEqualityCheck receiving a cleared WeakRef#763veksa wants to merge 1 commit into
Conversation
✅ Deploy Preview for reselect-docs canceled.
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
resultEqualityCheck receiving a cleared WeakRef
veksa
force-pushed
the
test/result-equality-cleared-weakref-750
branch
from
July 27, 2026 07:18
a51decb to
01f28f6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #750
The bug reported in #750 was actually fixed a while back in cea19b9, where the old
lastResult?.deref?.() ?? lastResultline was replaced with themaybeDerefhelper. Once that shipped in 5.2.0 the runtime error is gone.What was still missing is a test that locks the behavior in, so we don't accidentally regress it again. The original reporter tried to write one but couldn't get garbage collection to trigger reliably.
This adds that test. It builds a memoized selector, produces one result and registers it with a
FinalizationRegistry, then drops every strong reference so the result becomes collectible. Instead of a singleglobal.gc()call (which was flaky and just timed out), it runs a few GC passes and yields to the event loop between them until the finalization callback fires. At that pointlastResultis a clearedWeakRef, and the test asserts that a subsequent call never hands that rawWeakReftoresultEqualityCheck.The test is skipped when
global.gcisn't exposed. I confirmed it fails against the old?? lastResultlogic and passes with the currentmaybeDerefimplementation, so it genuinely guards the fix.