Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure waiters are discovered even if multiple versions exist #388

Merged
merged 2 commits into from
Apr 7, 2022

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Apr 4, 2022

Currently, we rely heavily on the highlander logic to ensure that we can only ever have one version of @ember/test-waiters in the build outpu. The reason for this is so that when someone calls hasPendingWaiters() we can reliably ensure that ALL waiters that have been registered (regardless of version mismatches and whatnot) are found.

Unfortunately, we cannot actually rely on the highlander logic to guarantee this "waiter map" uniqueness in Embroider builds (because the highlander logic is broken by the isolated nature of Embroiders compatibility layer).

This change migrates from a strict reliance on the highlander logic to guarantee the module scoped variable is shared globally to a mechanism of sharing the state on globalThis (with fallbacks for various other scenarios). Using this pattern allows us to avoid "caring" if the highlander code actually enforces a single version, while still ensuring that hasPendingWaiters will always return the right value.

It is likely that future changes will remove the usage of the highlander logic as of a certain version (that includes this change) and higher.

@rwjblue rwjblue added the bug Something isn't working label Apr 4, 2022
@rwjblue rwjblue requested a review from scalvert April 4, 2022 21:28
Currently, we rely heavily on the highlander logic to ensure that we can
**only** ever have one version of `@ember/test-waiters` in the build
outpu. The reason for this is so that when someone calls
`hasPendingWaiters()` we can reliably ensure that _**ALL**_ waiters that
have been registered (regardless of version mismatches and whatnot) are
found.

Unfortunately, we cannot actually rely on the highlander logic to
guarantee this "waiter map" uniqueness in Embroider builds (because the
highlander logic is broken by the isolated nature of Embroiders
compatibility layer).

This change migrates from a strict reliance on the highlander logic to
guarantee the module scoped variable is shared globally to a mechanism
of sharing the state on `globalThis` (with fallbacks for various other
scenarios). Using this pattern allows us to avoid "caring" if the
highlander code actually enforces a single version, while still ensuring
that `hasPendingWaiters` will always return the right value.

It is likely that future changes will remove the usage of the highlander
logic as of a certain version (that includes this change) and higher.
Co-authored-by: Steve Calvert <scalvert@linkedin.com>
@scalvert scalvert merged commit c44a60a into master Apr 7, 2022
@scalvert scalvert deleted the do-not-require-highlander branch April 7, 2022 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants