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

Most upvoted comments

I met the same issue when trying to set global timeout for http request

@jayphelps We don’t currently provide any mechanism to cancel scheduled work. So every operator which schedules, that work will be invoked regardless of whether or not anyone is subscribing anymore.

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.