Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeout does not call return on source iterator #280

Closed
backbone87 opened this issue Aug 25, 2019 · 2 comments · Fixed by #348
Closed

timeout does not call return on source iterator #280

backbone87 opened this issue Aug 25, 2019 · 2 comments · Fixed by #348

Comments

@backbone87
Copy link

https://github.com/ReactiveX/IxJS/blob/master/src/asynciterable/timeout.ts#L31

IxJS version: 2.5.3

Code to reproduce:

const ee = new EventEmitter();
try {
  const bar = await fromEvent(ee, 'foo').finally(() => void console.log('finally')).timeout(1000).take(1).toArray();
} catch (e) {
  console.log(e instanceof TimeoutError);
}

Expected behavior:
timeout returns the source iterator and therefore finally getting logged

Actual behavior:
timeout does not return the source iterator and therefore finally never gets logged

Additional information:
wrapping the whole while loop into a try ... finally works:

const it = this._source[Symbol.asyncIterator]();
try {
  while (1) {
    // ...
  }
} finally {
  await returnAsyncIterator(it);
}

also the timeout function is missing from AsyncIterableX.prototype

@backbone87
Copy link
Author

seems finally itself has the same problem. do i get something wrong about the concept or are the intermediate iterables responsible for returning the source iterables?

@trxcllnt
Copy link
Member

Got this implemented in the regular builds, but there seems to be a bug in closure-compiler: google/closure-compiler#3971

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants