How to find source of Possible Unhandled Promise Rejection [duplicate]
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?
react-native
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.
add a comment |
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?
react-native
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 youcomponentDidCatch
– 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
add a comment |
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?
react-native
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
react-native
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 youcomponentDidCatch
– 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
add a comment |
This life cycle method should help youcomponentDidCatch
– 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
add a comment |
3 Answers
3
active
oldest
votes
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
Unfortunately this does not trigger for promise rejections
– basbase
Nov 20 '18 at 13:54
add a comment |
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.
add a comment |
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
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
Unfortunately this does not trigger for promise rejections
– basbase
Nov 20 '18 at 13:54
add a comment |
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
Unfortunately this does not trigger for promise rejections
– basbase
Nov 20 '18 at 13:54
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 20 '18 at 14:40
PetrogadPetrogad
3,28252672
3,28252672
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Nov 20 '18 at 18:46
basbasebasbase
634111
634111
add a comment |
add a comment |
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