-
Notifications
You must be signed in to change notification settings - Fork 30k
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
bootstrap: run preload prior to --frozen-intrinsics #28940
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Credit to @ljharb for suggesting this :)
This is used to allow people to run polyfills.
Co-Authored-By: Anna Henningsen <github@addaleax.net>
547e58b
to
46c7534
Compare
One quick nonblocker question - how might i feature detect that a) this flag was invoked, whether via NODE_OPTIONS or a cli flag), as well as b) that this PR’s change was available, from runtime JS? |
@ljharb you can't detect if you are in a preload reliably to my knowledge, but you can detect the flag via |
@bmeck I'm not asking to test the ordering, more asking "how can i determine if my module that requires |
What would one do if they need to preload modules for purposes other than polyfilling but do not want the preloaded modules (or the modules they depend on) mess with the intrinsics? |
@ljharb I suspect the use case you are talking about is having polyfills that have assurances that intrinsics may not be modified by other preloads so they can use intrinsics directly instead of saving cached copies. @joyeecheung I suspect the use case you are talking about is replacing things like The answer to both is that it is not possible to have both mutable shared state and assurances about the integrity of that shared state. In general preloads are of conflicting interests in this timing and always have been the case regarding these 2 use cases. Only preloads that do not harm the integrity of the runtime (by mutating core, or improperly polyfilling) should be loaded in general. To this end, preload modules should probably be whitelisted when using policies, but that is out of scope of this PR. Users of these could always freeze things themselves if they want to ensure other preloads cannot touch them, but that would prevent preloads from composing or patching improper behavior of other preloads. Additionally, as core is hardened over time (using |
@bmeck Can't we make the timing configurable? e.g. adding values to |
@Joyee we could add my more times, but the problem would remain in the mutable timeframe so I don't think it actually does much / feel a different approach would be better (though I don't have a suggestion) |
would |
@devsnek what is the use case, |
@bmeck, I was just replying to the above question about configurable timing. |
I think a separate PR adding an API that freezes intrinsics (noop after first freeze) would be fine for people not wishing to use the flag; but that has different implications than a well defined timing and ability to audit/grant policy configuration for what runs prior to the freeze. Perhaps exposing that API could be a separate PR if people want to control timing manually? |
I don't have strong feelings on this, I just notice that an API would satisfy all timings.
satisfies:
and with
or any other time. I tend towards exposing mechanism, and leaving policy to users. |
@sam-github while it has similar effects it does not have the same overall impact on policy configuration. Exposing via API requires programmer vigilance on understanding when it may be called rather than providing a clear timing. |
Any reason to wait on landing this? @bmeck @joyeecheung |
@Trott My previous comments are non-blocking. |
@Trott seems like it is fine to land as nothing seems blocking. |
This is used to allow people to run polyfills. Co-Authored-By: Anna Henningsen <github@addaleax.net> PR-URL: #28940 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in 85898e0 |
This is used to allow people to run polyfills. Co-Authored-By: Anna Henningsen <github@addaleax.net> PR-URL: #28940 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This is used to allow people to run polyfills.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes