I am trying to identify if my resource is failing due to timeouts and at the same time want to analyze how many failures are with timeouts. So, I am trying to attach one timeout with request which will simply log saying request not recieved within time, without throwing error and another timeout will throw the error. Something like this:
const checkResponseTimeouts = async () => {
const data = await firstValueFrom(
from(getData())
.pipe(
timeout({
each: 2500,
with: ( sub ) => { // this is not the way it works, but just to make example
console.log("response not recieved within 2.5 seconds");
return true;
},
})
)
.pipe(
timeout({
each: 10000,
with: () => {
console.log("request timed out after 10 seconds");
return throwError(() => new Error("Some error"));
},
})
)
);
return data;
};
The code above is not correct, its just for demonstrating the problem. I am new to RxJS and few things seems confusing to me. Help will be much appreciated.