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

forEach does not unsubscribe appropriately when next handler throws on synchronous emissions #6676

Closed
benlesh opened this issue Nov 15, 2021 · 1 comment · Fixed by #6677
Closed
Assignees
Labels
7.x bug

Comments

@benlesh
Copy link
Member

@benlesh benlesh commented Nov 15, 2021

The current implementation is not properly unsubscribing from the source when the next handler throws in this scenario:

of(1, 2, 3).pipe(
  tap(console.log),
)
.forEach(() => {
  throw new Error('test error');
})
.catch(err => console.log(err.message));

// Logs:
1
2
3
"test error"

// Would expect just:
"test error"

Stackblitz here

@benlesh benlesh self-assigned this Nov 15, 2021
@benlesh benlesh added 7.x bug labels Nov 15, 2021
benlesh added a commit to benlesh/rxjs that referenced this issue Nov 15, 2021
@benlesh
Copy link
Member Author

@benlesh benlesh commented Nov 15, 2021

This is so glaring to me, I'm shocked it's not been reported. I guess it's an edge case, really. How often do people throw errors in the next handler of a forEach on a synchronous observable? But still. It's CRAZY to me that this wasn't caught before. And even worse: I didn't catch it while updating the code, and it passed review! haha.

Well, at least it's caught now.

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

Successfully merging a pull request may close this issue.

1 participant