How to debug "Unhandled Promise rejection:" promise

I have built an app and I’m testing it on a device, in the LogCat I can see:

11-14 10:40:24.778 12826-12826/io.ionic.starter D/SystemWebChromeClient: file:///android_asset/www/build/polyfills.js: Line 3 : Unhandled Promise rejection:
11-14 10:40:24.778 12826-12826/io.ionic.starter I/chromium: [INFO:CONSOLE(3)] "Unhandled Promise rejection:", source: file:///android_asset/www/build/polyfills.js (3)

Obviously I do have a problem somewhere, but I don’t know how to locate it, it does give me some more errors:

11-14 10:40:36.901 12826-12826/io.ionic.starter D/SystemWebChromeClient: ng:///AppModule/JobSelector.ngfactory.js: Line 441 : ERROR
11-14 10:40:36.901 12826-12826/io.ionic.starter I/chromium: [INFO:CONSOLE(441)] "ERROR", source: ng:///AppModule/JobSelector.ngfactory.js (441)
11-14 10:40:36.904 12826-12826/io.ionic.starter D/SystemWebChromeClient: ng:///AppModule/JobSelector.ngfactory.js: Line 441 : ERROR CONTEXT
11-14 10:40:36.904 12826-12826/io.ionic.starter I/chromium: [INFO:CONSOLE(441)] "ERROR CONTEXT", source: ng:///AppModule/JobSelector.ngfactory.js (441)
11-14 10:40:36.915 12826-12826/io.ionic.starter D/SystemWebChromeClient: ng:///AppModule/JobSelector.ngfactory.js: Line 506 : ERROR
11-14 10:40:36.915 12826-12826/io.ionic.starter I/chromium: [INFO:CONSOLE(506)] "ERROR", source: ng:///AppModule/JobSelector.ngfactory.js (506)
11-14 10:40:36.917 12826-12826/io.ionic.starter D/SystemWebChromeClient: ng:///AppModule/JobSelector.ngfactory.js: Line 506 : ERROR CONTEXT
11-14 10:40:36.917 12826-12826/io.ionic.starter I/chromium: [INFO:CONSOLE(506)] "ERROR CONTEXT", source: ng:///AppModule/JobSelector.ngfactory.js (506)

Which is all good but I’m not able to find the JobSelector.ngfactory.js
How can I identify where the error is in the source code, in order to be able to fix it?

Thanks.

Look for code where you consume a promise. Let’s say you have

async x() {
  return new Promise((resolve, reject) => {
    resolve(true)
  })
}

And you have some other code somewhere that consumes that async function:

resolved = function(retval) {...}
rejected = function(error) {...}
x().then((resolved, rejected)=>{
})

Except, your code does not have rejected part. Yours looks something like this:

resolved = function(retval) {...}

x().then((resolved)=>{
})

Which is fine most of the time, but in your case, the promise has rejected (failed) at some point and you aren’t handling that case.

Most probably, the problem is not in the JobSelector, somehow, somewhere you have an unhandled promise rejection (I hope this clears what that error message means).