Is it safe to resolve a promise multiple times?

前端 未结 7 857
旧时难觅i
旧时难觅i 2021-01-31 06:33

I have an i18n service in my application which contains the following code:

var i18nService = function() {
  this.ensureLocaleIsLoaded = function() {
    if( !th         


        
7条回答
  •  终归单人心
    2021-01-31 07:12

    No. It is not safe to resolve/reject promise multiple times. It is basically a bug, that is hard to catch, becasue it can be not always reproducible.

    There is pattern that can be used to trace such issues in debug time. Great lecture on this topic: Ruben Bridgewater — Error handling: doing it right! (the part related to the question is around 40 min)

提交回复
热议问题