then / promise

Bare bones Promises/A+ implementation
https://www.promisejs.org
MIT License
2.58k stars 312 forks source link

[BUG]Why this promise execute queue is not same with v8 Promise。 #175

Closed jjkbb123 closed 2 years ago

jjkbb123 commented 2 years ago

example

Promise.resolve()
  .then(_ => {
    console.log(0)
    return Promise.resolve()
  })
  .then(_ => {
    console.log(1)
  })

Promise.resolve()
  .then(_ => {Ï
    console.log(3)
  })
  .then(_ => {
    console.log(4)
  })
  .then(_ => {
    console.log(5)
  })
  .then(_ => {
    console.log(6)
  })

v8 Promise: 0 3 4 5 1 6 this Promise: 0 3 1 4 5 6

edef1c commented 2 years ago

Neither the execution ordering of Chrome/V8 Promise callbacks, nor that of then/promise, are defined, documented, or stable guarantees. It is simply undefined, and even it being stable for a given version of the Promise implementation ought not to be relied on.