-
Notifications
You must be signed in to change notification settings - Fork 478
Description
The previous JS.md includes this phrase in a the definition of instantiation:
After the instantiation task runs and before any subsequent steps are taken, other unspecified asynchronous tasks may be run.
The current JS API spec doesn't include this delay in its definition of instantiation. In #webkit, @domenic and @kmiller68 discussed this change. @kmiller68 raised the concern that this is a change over what was previously agreed, and that JSC does make this kind of delay, though it'd be possible to remove it. (Anyone know where the #webkit logs are?)
My misunderstanding when writing the spec initially was that, because things were "in parallel", any more delays would be unobservable and don't need specific spec text. However, the current text has moved to more specific "queue a task" language, and instantiation actually executes JS code just before resolving a promise.
I see three ways we could specify things now:
- Prohibit additional asynchronous work, as in the current spec text
- "Queue a task" to resolve the Promise
- Permit either of 1. and 2.
Because the execution order of task queues and Promises is pretty tightly specified, there's an observable difference possible between 1. and 2. The current spec text immediately resolves the Promise, so no HTML tasks will run in between reading the properties of the import object and calling then then
callbacks that are attached to the Promise for the instantiated module. Further, the microtask queue order is specified, so there is even more detail. By contrast, in the semantics of 2., the microtask queue would be drained and some HTML tasks may run before going back and calling the then
callbacks for the Promise.
I think option 3 corresponds to the previously documented semantics in JS.md, but at the same time, the trend among modern JS/web specifications seems to be to very tightly specify the ordering one way or the other.
Which of these three options should we choose?