Comments (9)
At least we could close this issue, since this became a debugging session :)
from scheduling-apis.
Isn't this about Promise chaining. Run the following in a browser's web console and check how the outer Promise is fullfilled:
var p = new Promise((resolve) => { resolve(new Promise((resolveInner) => { setTimeout(resolveInner, 1000); })); }); console.log(p); setTimeout(() => {console.log(p)}, 2000 );
But I could very well miss still something.
from scheduling-apis.
A bit modified version which rejects the inner but resolves the outer
var p = new Promise((resolve) => { resolve(new Promise((resolveInner, rejectInner) => { setTimeout(rejectInner, 1000); })); }); console.log(p); setTimeout(() => {console.log(p)}, 2000 );
that is close to the testcase and p is rejected because of 6.2
from scheduling-apis.
I was thinking this should be covered by promise chaining at first too, but I think it's different -- in the test case we're rejecting the outer after it was resolved with the inner promise, something like:
var p = new Promise((resolve, rejectOuter) => { resolve(new Promise((resolveInner, rejectInner) => { setTimeout(rejectOuter, 1000); })); }); console.log(p); setTimeout(() => {console.log(p)}, 2000 );
(controller.abort == rejectOuter).
^^ that gets stuck at for me in FF and Chrome, which makes sense because the outer is dependent on inner. I believe this would be the scenario if the abort steps in 6.2 runs and result
is already resolved with a pending promise.
from scheduling-apis.
ah, I see. But the promise isn't yet resolved (because of the inner), yet does Chrome in the test get resolved p... because the function eventually returns. (I'll need to play with this a bit more tomorrow :) )
from scheduling-apis.
I filed a Gecko bug about this https://bugzilla.mozilla.org/show_bug.cgi?id=1767087
It is possible that an optimization in Gecko or Spidermonkey kicks in when it shouldn't, @arai-a might know better.
from scheduling-apis.
This was mis-optimization in SpiderMonkey, and p
shouldn't be rejected.
Resolving promise should set [[AlreadyResolved]].[[Value]]
to true
, to prevent subsequent resolve/reject call.
https://tc39.es/ecma262/#sec-promise-resolve-functions
Then, SpiderMonkey doesn't create Promise Resolve Function and Promise Reject Function if they're known not to be exposed to user JS code, but resolve/reject is done only from C++ code internally or with public APIs,
and in that case the [[AlreadyResolved]].[[Value]]
check wasn't performed.
Fixing in bug 1767087.
from scheduling-apis.
Fixed by web-platform-tests/wpt@146851f
from scheduling-apis.
Thanks @arai-a and @smaug----!
Thinking about the behavior a bit more, the current behavior here seems reasonable? To abort a running async task (e.g. in response to user input), the task's promise would need to be rejected along with the rest of the task. Using signal.throwIfAborted()
in userland at various checkpoints accomplishes this. It might be desirable to do this automatically on signal abort, but I think we'd need signal propagation of some kind — including through the JS layer. We might explore that at some point in conjunction with async task priority propagation.
from scheduling-apis.
Related Issues (20)
- TaskController constructor should probably take a dictionary instead of an optional priority HOT 2
- Fill in security and privacy considerations
- Link to the spec from appropriate places HOT 1
- Document minimum version for local testing of TaskPriorityChangeEvent and previousPriority
- Publish postTask Polyfill HOT 1
- schedule a postTask task doesn't always return a promise
- Questions around this proposal HOT 6
- [question] The relationship between the scheduling APIs and built-in functions. HOT 2
- Standardization HOT 2
- [Suggestion] isTaskPending
- https://wicg.github.io/scheduling-apis/#sec-scheduler-alg-scheduling-tasks doesn't explain what happens if the associated document isn't fully active HOT 2
- self.scheduler should be [[Replaceable]] HOT 2
- How do we measure the effectiveness of this API? HOT 9
- Offering my help (from the perspective of building a userspace scheduler)
- Broken references in Prioritized Task Scheduling
- Specify event loop integration / priority intent HOT 6
- scheduler.yield seems to supersede image loading operations HOT 4
- Structured concurrency and cancellation
- Need to remove the entry from the task queue maps when the queue is empty HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scheduling-apis.