Regarding Promises/A+ Specification, is a promise ever allowed to never resolve or reject?

后端 未结 1 1843
情书的邮戳
情书的邮戳 2021-01-25 03:34

In the Promises/A+ standard, I am wondering if a promise needs to resolve or reject eventually. By this I mean a promise X with the property that under no condition wha

相关标签:
1条回答
  • 2021-01-25 03:59

    No, the spec does not mandate this. There is no restriction on how long a promise should take to settle. And that includes an infinitely long time - known as a never-resolving/never-settling promise or forever-pending promise. (see also promise terminology)
    The term may is used deliberately here, and does carry the conventional meaning.

    There even exist promise implementations that offer a Promise.never primitive (e.g. in creed) to optimise the memory consumption for the case when you know that your promise won't settle.

    0 讨论(0)
提交回复
热议问题