Skip to content

Mark fewer modules as circuit breakers - #98923

Draft
lukesandberg wants to merge 1 commit into
optimize-constant-reexport-bindingsfrom
fewer-circuit-breaker-modules
Draft

lukesandberg wants to merge 1 commit into
optimize-constant-reexport-bindingsfrom
fewer-circuit-breaker-modules

Conversation

@lukesandberg

@lukesandberg lukesandberg commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

To preserve semantics, when generating exports for ESM modules that have cyclic dependencies we need to find a way to break the cycle using early bound 'getter' exports.

Currently the semantics are conservative, all modules in a cycle are tagged as breakers. This PR changes that to instead only mark cycle entry points and 'back edges' as circuit breakers. This increases the scope for other ESM optimizations

@lukesandberg
lukesandberg added this pull request to stack #98899 September 19, 2026 00:47
@github-actions

github-actions Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: a466b1a

@lukesandberg
lukesandberg force-pushed the fewer-circuit-breaker-modules branch from bfd63dc to a466b1a Compare September 19, 2026 00:47
// Only the modules that can be read before they finish evaluating need to break
// the cycle. The rest are fully evaluated by the time anything reads them, so they
// can keep exporting values instead of getters.
export_circuit_breakers.extend(cycle.partially_observable.iter().map(|n| **n));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

partialily_observable makes sense as a name for this usecase but not for the graph traversal

back_edge_targets still seems correct

@lukesandberg lukesandberg changed the title Mark fewer modules as circuite breakers Mark fewer modules as circuit breakers Sep 19, 2026
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.

1 participant