-
Notifications
You must be signed in to change notification settings - Fork 24
Description
https://www.w3.org/2001/tag/doc/promises-guide#shorthand-creating says:
"A promise resolved with x" or "x resolved as a promise" is shorthand for the result of
Promise.resolve(x)
, using the initial value ofPromise.resolve
.
If x is a promise this can cause JavaScript to run, due to the definition of PromiseResolve in ECMASCRIPT, step 2a. Specifically, it calls Get(x, "constructor")
. If Promise.prototype.constructor
has been set on the global object, it will be consulted. If a getter has been set, it will be executed.
This is a problem for the CreateReadableStream() operation in the streams standard. It has a note that "CreateReadableStream throws an exception if and only if the supplied startAlgorithm throws.". This will not be true if startAlgorithm returns a Promise and the global Promise.prototype.constructor
has been messed with, which is surprising.
It is not clear whether this should be fixed here or in the streams standard.