rxjs: .timeout doesn't cancel setTimeout
RxJS version: rxjs beta.12 Code to reproduce:
Expected behavior: cancel the internal setTimeout when it’s not needed anymore (after first response)
Actual behavior: setTimeout still resolves which delays universal since zone.js tracks it Additional information:
Angular Universal uses zone.js to keep track of async calls before rendering. There seems to be a problem with .timeout
on an http call
here’s a repro
https://github.com/gdi2290/universal-starter-rxjs-timeout-issue/blob/master/src/app/shared/api.service.ts#L23
npm run watch:dev
comment out that line
there are some console logs on the server that show the stable time taking 2000ms with the timeout rather than less than 1ms
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (17 by maintainers)
Commits related to this issue
- fix(timeout): Cancels scheduled timeout, if no longer needed fixes #2134 — committed to jayphelps/rxjs by jayphelps 8 years ago
- fix(timeout): Update timeout and timeoutWith to recycle their scheduled timeout actions. The timeout and timeoutWith operators should dispose their scheduled timeout actions on unsubscription. Also,... — committed to trxcllnt/rxjs by trxcllnt 8 years ago
- fix(timeout): Update timeout and timeoutWith to recycle their scheduled timeout actions. The timeout and timeoutWith operators should dispose their scheduled timeout actions on unsubscription. Also,... — committed to trxcllnt/rxjs by trxcllnt 8 years ago
- fix(timeout): Update timeout and timeoutWith to recycle their scheduled timeout actions. The timeout and timeoutWith operators should dispose their scheduled timeout actions on unsubscription. Also,... — committed to jayphelps/rxjs by trxcllnt 8 years ago
- fix(timeout): Cancels scheduled timeout, if no longer needed fixes #2134 — committed to jayphelps/rxjs by jayphelps 8 years ago
- fix(timeout): Update timeout and timeoutWith to recycle their scheduled timeout actions. The timeout and timeoutWith operators should dispose their scheduled timeout actions on unsubscription. Also,... — committed to jayphelps/rxjs by trxcllnt 8 years ago
- fix(timeout): Cancels scheduled timeout, if no longer needed fixes #2134 — committed to trxcllnt/rxjs by jayphelps 8 years ago
- fix(timeout): Cancels scheduled timeout, if no longer needed fixes #2134 — committed to jayphelps/rxjs by jayphelps 8 years ago
- fix(timeout): Cancels scheduled timeout, if no longer needed * fix(timeout): Cancels scheduled timeout, if no longer needed fixes #2134 * fix(timeoutWith): Cancels scheduled timeout, if no long... — committed to ReactiveX/rxjs by jayphelps 7 years ago
I met the same issue when trying to set global timeout for http request
This is not the case. Canceling an AsyncAction before the due time will always clear the scheduled interval, full stop. Like @david-driscoll has pointed out, the
timeout
operator needs to clean up after itself.@jayphelps you are correct, it did, which should be the default behavior to always tear down upon cancellation/completion and not just removing the item from the queue.