Skip to content

Simplify MODULARIZE code to always use async factory function #24727

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jul 16, 2025

The docs here were wrong. We have the addRunDependency system that can delay module's readiness for an arbitrary amount of time, even if async compilation is disabled.

This addRunDependency system does not exist in MINUMAL_RUTTIME, so in some cases we can avoid the ready promise in MINIMAL_RUNTIME mode, but that is a pretty subtle distinction that only applies to MINIMAL_RUNTIME. Also even in this mode we were still marking the factory function as async (note the lack of USE_READY_PROMISE in the existing condition).

The docs here were wrong.  We have the `addRunDependency` system that
can delay module's readiness for an arbitrary amount of time, even if
async compilation is disabled.

This `addRunDependency` system does not exist in MINUMAL_RUTTIME, so in
some cases we can avoid the ready promise in MINIMAL_RUNTIME mode, but
that is a pretty subtle distinction that only applies to MINIMAL_RUNTIME.
Also even in this mode we were still marking the factory function as
async (note the lack of USE_READY_PROMISE in the existing condition).
@sbc100 sbc100 force-pushed the simplify_modularize branch from a18ff2d to d61be25 Compare July 16, 2025 23:13
@sbc100 sbc100 requested a review from kripken July 16, 2025 23:13
(If WASM_ASYNC_COMPILATION is off, that is, if compilation is
*synchronous*, then it would not make sense to return a Promise, and instead
the Module object itself is returned, which is ready to be used.)
the code wrapped in an async function. This functions returns a promise that
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
the code wrapped in an async function. This functions returns a promise that
the code wrapped in an async function. This function returns a promise that

*synchronous*, then it would not make sense to return a Promise, and instead
the Module object itself is returned, which is ready to be used.)
the code wrapped in an async function. This functions returns a promise that
resolves to a module instance when once it is safe to run the compiled code
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
resolves to a module instance when once it is safe to run the compiled code
resolves to a module instance when it is safe to run the compiled code

Copy link
Member

Choose a reason for hiding this comment

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

(could also be "once", but not "when once" together, I think)

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.

2 participants