samdenty / console-feed

Captures console.log's into a React Component 🔥
https://stackblitz.com/~/github.com/samdenty/console-feed
MIT License
662 stars 110 forks source link

Inside promise, errors are not being displaying in the console #95

Open isaacking5 opened 2 years ago

isaacking5 commented 2 years ago

Description

When I am trying to see the error logs which occur in promise, but in console-feed no errors are being displayed though those errors appear in a browser console. But the with the same code which is outside the promise those errors are displaying in console-feed console.

code without promise

console.log("test".includ('test'))

above code WORKING AS EXPECTED, but

code inside the promise

new Promise((resolve) => {
  resolve();
}).then(() => stringIncludesTest());

function stringIncludesTest() {
  let dummyString = "test";
  console.log(dummyString.incldes("st"));
}

EXPECTED Error should be display as :- ""a.incldes is not a function""

ACTUAL Nothing is in console

NOTE : Browser console showing appropriate errors

StephenGrider commented 2 years ago

One possible workaround is to capture the event generated by the unhandledrejcetion and manually log the error. Example:

window.addEventListener('unhandledrejection', (e: any) => {
  console.error(e.reason);
});