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

Break eager cycle for "deprecate" function #20714

Merged
merged 1 commit into from
Jul 11, 2024
Merged

Break eager cycle for "deprecate" function #20714

merged 1 commit into from
Jul 11, 2024

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Jul 5, 2024

There is a module cycle involving @ember/debug/index and @ember/debug/lib/deprecate, and it's somewhat intentional since both are sharing mutable state with the other that's intended to allow users to replace the implementations.

The cycle wouldn't be a big deal except for the fact that index eagerly consumes the deprecate function from lib/deprecate, which means that if you get unlucky in the evaluation order it just explodes.

There's no need to eagerly consume it. This PR makes the consumption lazy.

In general export function is resilient to cycles in a way that export let is not. There are a bunch more places in @ember/debug that are using export let when they should probably be using export function instead, especially because these function are supposed to always be present (even in prod they are no-ops, not missing).

(All of this is only noticeable when running with real ES modules under embroider. The classic build happens to have a reliable ordering that doesn't break.)

There is a module cycle involving `@ember/debug/index` and `@ember/debug/lib/deprecate`, and it's somewhat intentional since both are sharing mutable state with the other that's intended to allow users to replace the implementations.

The cycle wouldn't be a big deal except for the fact that index **eagerly** consumes the `deprecate` function from `lib/deprecate`, which means that if you get unlucky in the evaluation order it just explodes.

There's no need to eagerly consume it. This PR makes the consumption lazy.

In general `export function` is resilient to cycles in a way that `export let` is not. There are a bunch more places in `@ember/debug` that are using `export let` when they should probably be using `export function` instead, especially because these function are supposed to *always* be present (even in prod they are no-ops, not missing).
@ef4 ef4 added the Bug label Jul 5, 2024
@ef4 ef4 merged commit a5e33a1 into main Jul 11, 2024
26 checks passed
@ef4 ef4 deleted the debug-cycle branch July 11, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants