I never user RxJS, but now I'm working on a project which uses it.
I apologize if my question is not so clear, please do not hesitate to request for clarifications/edits.
I have an Observable which (in case of no errors) resolves very fast, but there is a timeout just in case...
I noticed that my Node.js process does not exits untill the timeout is not expired...
If I comment out this piece of code:
observable.pipe(
timeout(3* 60 * 1000),
catchError(() => throwError(() => new Error("timeout")))
);
the Node.js process exits without any problem.
Is there some way to unref an RxJS timeout?
I tried out a very simple example based from RXJS doc:
import { of } from 'rxjs';
import { concatMap, timeout, catchError, delay } from 'rxjs/operators';
// simulate request
function makeRequest(timeToDelay) {
return of('Request Complete!').pipe(delay(timeToDelay));
}
of(200)
.pipe(
concatMap(duration =>
makeRequest(duration).pipe(
timeout(10500),
catchError(() => throwError(() => new Error("timeout")))
//catchError(error => of(`Request timed out after: ${duration}`))
)
)
)
.subscribe(val => console.log(val));
I am on Window 10, on the task manager, the process appear and disappear without waiting the timeout (10500ms).
However, when closing git bash I have:
But only if I launched my process like that node index.js & (& at the end to disconnect from terminal).
Unsure what the implications of the terminal telling me the process is still running, when the task manager says there is no running node process.