How to find source of Possible Unhandled Promise Rejection [duplicate]












0
















This question already has an answer here:




  • Global unhandledrejection listener in React Native

    1 answer




While working on a large inherited codebase I stumbled upon this not so helpful warning:



Possible Unhandled Promise Rejection (id: 0):
true

console.warn @ YellowBox.js:67
onUnhandled @ Promise.js:43
onUnhandled @ rejection-tracking.js:71
(anonymous) @ JSTimers.js:256
_callTimer @ JSTimers.js:152
callTimers @ JSTimers.js:405
__callFunction @ MessageQueue.js:349
(anonymous) @ MessageQueue.js:106
__guard @ MessageQueue.js:297
callFunctionReturnFlushedQueue @ MessageQueue.js:105
(anonymous) @ debuggerWorker.js:72


Is possible to get the file and line number of the promise that causes this rejection, without going through the entire code and adding catch() everywhere?










share|improve this question













marked as duplicate by basbase, Community Nov 20 '18 at 18:55


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • This life cycle method should help you componentDidCatch

    – Raaj Nadar
    Nov 20 '18 at 13:02











  • Are you using fetch or axis to get your data? With axios you could use the interceptors feature and add more logging there. You could also do that with fetch I think.

    – needsleep
    Nov 20 '18 at 14:45













  • @needsleep the app uses fetch, but the issue goes for all unhandled promises

    – basbase
    Nov 20 '18 at 18:11
















0
















This question already has an answer here:




  • Global unhandledrejection listener in React Native

    1 answer




While working on a large inherited codebase I stumbled upon this not so helpful warning:



Possible Unhandled Promise Rejection (id: 0):
true

console.warn @ YellowBox.js:67
onUnhandled @ Promise.js:43
onUnhandled @ rejection-tracking.js:71
(anonymous) @ JSTimers.js:256
_callTimer @ JSTimers.js:152
callTimers @ JSTimers.js:405
__callFunction @ MessageQueue.js:349
(anonymous) @ MessageQueue.js:106
__guard @ MessageQueue.js:297
callFunctionReturnFlushedQueue @ MessageQueue.js:105
(anonymous) @ debuggerWorker.js:72


Is possible to get the file and line number of the promise that causes this rejection, without going through the entire code and adding catch() everywhere?










share|improve this question













marked as duplicate by basbase, Community Nov 20 '18 at 18:55


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • This life cycle method should help you componentDidCatch

    – Raaj Nadar
    Nov 20 '18 at 13:02











  • Are you using fetch or axis to get your data? With axios you could use the interceptors feature and add more logging there. You could also do that with fetch I think.

    – needsleep
    Nov 20 '18 at 14:45













  • @needsleep the app uses fetch, but the issue goes for all unhandled promises

    – basbase
    Nov 20 '18 at 18:11














0












0








0









This question already has an answer here:




  • Global unhandledrejection listener in React Native

    1 answer




While working on a large inherited codebase I stumbled upon this not so helpful warning:



Possible Unhandled Promise Rejection (id: 0):
true

console.warn @ YellowBox.js:67
onUnhandled @ Promise.js:43
onUnhandled @ rejection-tracking.js:71
(anonymous) @ JSTimers.js:256
_callTimer @ JSTimers.js:152
callTimers @ JSTimers.js:405
__callFunction @ MessageQueue.js:349
(anonymous) @ MessageQueue.js:106
__guard @ MessageQueue.js:297
callFunctionReturnFlushedQueue @ MessageQueue.js:105
(anonymous) @ debuggerWorker.js:72


Is possible to get the file and line number of the promise that causes this rejection, without going through the entire code and adding catch() everywhere?










share|improve this question















This question already has an answer here:




  • Global unhandledrejection listener in React Native

    1 answer




While working on a large inherited codebase I stumbled upon this not so helpful warning:



Possible Unhandled Promise Rejection (id: 0):
true

console.warn @ YellowBox.js:67
onUnhandled @ Promise.js:43
onUnhandled @ rejection-tracking.js:71
(anonymous) @ JSTimers.js:256
_callTimer @ JSTimers.js:152
callTimers @ JSTimers.js:405
__callFunction @ MessageQueue.js:349
(anonymous) @ MessageQueue.js:106
__guard @ MessageQueue.js:297
callFunctionReturnFlushedQueue @ MessageQueue.js:105
(anonymous) @ debuggerWorker.js:72


Is possible to get the file and line number of the promise that causes this rejection, without going through the entire code and adding catch() everywhere?





This question already has an answer here:




  • Global unhandledrejection listener in React Native

    1 answer








react-native






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 12:02









basbasebasbase

634111




634111




marked as duplicate by basbase, Community Nov 20 '18 at 18:55


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by basbase, Community Nov 20 '18 at 18:55


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • This life cycle method should help you componentDidCatch

    – Raaj Nadar
    Nov 20 '18 at 13:02











  • Are you using fetch or axis to get your data? With axios you could use the interceptors feature and add more logging there. You could also do that with fetch I think.

    – needsleep
    Nov 20 '18 at 14:45













  • @needsleep the app uses fetch, but the issue goes for all unhandled promises

    – basbase
    Nov 20 '18 at 18:11



















  • This life cycle method should help you componentDidCatch

    – Raaj Nadar
    Nov 20 '18 at 13:02











  • Are you using fetch or axis to get your data? With axios you could use the interceptors feature and add more logging there. You could also do that with fetch I think.

    – needsleep
    Nov 20 '18 at 14:45













  • @needsleep the app uses fetch, but the issue goes for all unhandled promises

    – basbase
    Nov 20 '18 at 18:11

















This life cycle method should help you componentDidCatch

– Raaj Nadar
Nov 20 '18 at 13:02





This life cycle method should help you componentDidCatch

– Raaj Nadar
Nov 20 '18 at 13:02













Are you using fetch or axis to get your data? With axios you could use the interceptors feature and add more logging there. You could also do that with fetch I think.

– needsleep
Nov 20 '18 at 14:45







Are you using fetch or axis to get your data? With axios you could use the interceptors feature and add more logging there. You could also do that with fetch I think.

– needsleep
Nov 20 '18 at 14:45















@needsleep the app uses fetch, but the issue goes for all unhandled promises

– basbase
Nov 20 '18 at 18:11





@needsleep the app uses fetch, but the issue goes for all unhandled promises

– basbase
Nov 20 '18 at 18:11












3 Answers
3






active

oldest

votes


















0














You can do something like this in you root component.



componentDidCatch(error, info) {
console.log(error)
console.log(info)
}



Don't log you error instead send it to you database so that you can fix the issue with more information.




Read more about componentDidCatch() life cycle method here






share|improve this answer
























  • Unfortunately this does not trigger for promise rejections

    – basbase
    Nov 20 '18 at 13:54



















0














Your best bet would be to look in onUnhandled @ rejection-tracking.js:71. I'm guessing it's in that file that the rejection is being initiated from.






share|improve this answer































    0














    The solution is to use a third party promise library which keeps additional stack traces, like Bluebird, as described in this answer: https://stackoverflow.com/a/49129335/10236907






    share|improve this answer






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      You can do something like this in you root component.



      componentDidCatch(error, info) {
      console.log(error)
      console.log(info)
      }



      Don't log you error instead send it to you database so that you can fix the issue with more information.




      Read more about componentDidCatch() life cycle method here






      share|improve this answer
























      • Unfortunately this does not trigger for promise rejections

        – basbase
        Nov 20 '18 at 13:54
















      0














      You can do something like this in you root component.



      componentDidCatch(error, info) {
      console.log(error)
      console.log(info)
      }



      Don't log you error instead send it to you database so that you can fix the issue with more information.




      Read more about componentDidCatch() life cycle method here






      share|improve this answer
























      • Unfortunately this does not trigger for promise rejections

        – basbase
        Nov 20 '18 at 13:54














      0












      0








      0







      You can do something like this in you root component.



      componentDidCatch(error, info) {
      console.log(error)
      console.log(info)
      }



      Don't log you error instead send it to you database so that you can fix the issue with more information.




      Read more about componentDidCatch() life cycle method here






      share|improve this answer













      You can do something like this in you root component.



      componentDidCatch(error, info) {
      console.log(error)
      console.log(info)
      }



      Don't log you error instead send it to you database so that you can fix the issue with more information.




      Read more about componentDidCatch() life cycle method here







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 20 '18 at 13:29









      Raaj NadarRaaj Nadar

      1,12621220




      1,12621220













      • Unfortunately this does not trigger for promise rejections

        – basbase
        Nov 20 '18 at 13:54



















      • Unfortunately this does not trigger for promise rejections

        – basbase
        Nov 20 '18 at 13:54

















      Unfortunately this does not trigger for promise rejections

      – basbase
      Nov 20 '18 at 13:54





      Unfortunately this does not trigger for promise rejections

      – basbase
      Nov 20 '18 at 13:54













      0














      Your best bet would be to look in onUnhandled @ rejection-tracking.js:71. I'm guessing it's in that file that the rejection is being initiated from.






      share|improve this answer




























        0














        Your best bet would be to look in onUnhandled @ rejection-tracking.js:71. I'm guessing it's in that file that the rejection is being initiated from.






        share|improve this answer


























          0












          0








          0







          Your best bet would be to look in onUnhandled @ rejection-tracking.js:71. I'm guessing it's in that file that the rejection is being initiated from.






          share|improve this answer













          Your best bet would be to look in onUnhandled @ rejection-tracking.js:71. I'm guessing it's in that file that the rejection is being initiated from.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 14:40









          PetrogadPetrogad

          3,28252672




          3,28252672























              0














              The solution is to use a third party promise library which keeps additional stack traces, like Bluebird, as described in this answer: https://stackoverflow.com/a/49129335/10236907






              share|improve this answer




























                0














                The solution is to use a third party promise library which keeps additional stack traces, like Bluebird, as described in this answer: https://stackoverflow.com/a/49129335/10236907






                share|improve this answer


























                  0












                  0








                  0







                  The solution is to use a third party promise library which keeps additional stack traces, like Bluebird, as described in this answer: https://stackoverflow.com/a/49129335/10236907






                  share|improve this answer













                  The solution is to use a third party promise library which keeps additional stack traces, like Bluebird, as described in this answer: https://stackoverflow.com/a/49129335/10236907







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 20 '18 at 18:46









                  basbasebasbase

                  634111




                  634111















                      Popular posts from this blog

                      Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                      ComboBox Display Member on multiple fields

                      Is it possible to collect Nectar points via Trainline?