chore: fix latest compile TS and Node 20 workflow failures #7512
+35
−28
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.
Description:
In PR #7511 I discovered that Node 18 tests are working fine, but it looks like the latest Node 20 (
20.18.0
) which the Node 20 job is configured to use, has actually implementedFinalizationRegistry
which was added to the tests 4 years ago (!) but has not actually been in use because of it not being present globally in Node until now.This is obviously a very surprising discovery that this test code has not actually ever been executed in the last 4 years, and in reading the MDN entry for
FinalizationRegistry
(a thing I was not familiar with at all), it seems like something we'd want to avoid in deterministic tests across multiple environments.Therefore I replaced its usage entirely with a
WeakRef
which should hopefully cover the desired logic on Node v20.(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry)
The PR then ultimately also fixes the long standing TS compilation issues with latest TS.