cloud-sdk-js
cloud-sdk-js copied to clipboard
Catch Unresolved Promises
Our current implementation of the timeout is based on a race conditions. Here is a minimal example illsutrating the issue:
const timeoutSuccss = 1000
const timeoutFailure = 3000
async function promiseTest(){
const success = new Promise((resolve, reject) =>
setTimeout(
() => resolve('Success!'),
timeoutSuccss
));
const failure = new Promise((resolve, reject) =>
setTimeout(
() => reject('Failure!'),
timeoutFailure
)
);
const result = await Promise.race([success,failure])
console.log(result)
}
promiseTest()
The issue is that the faulure promise is kept open even if the race is lost and at a certain later time in Visual studio code your debugger stops at the uncaught exception if you enable the options:

One way to solve this would be to add a
failure.catch(()=>'catch it if success won the race.')
after the promise.race resolved successfully.
TODO
- [ ] Investigate if there is a lib to wrap a promise in a timeout.
- [ ] Implement a solution to catch to running timeout promise (search for the timeoutPromise which should be used or the Promise.race usage)
Acceptance Criteria
- [ ] There are no uncaught exceptions if the timeout promise is irrelavant.
Include this here: https://github.com/SAP/cloud-sdk-backlog/issues/667
We will not work on this, due to the current priority.