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

zip() throws (swallowed) error when closed synchronously in next() handler #6716

Open
chrisguttandin opened this issue Dec 11, 2021 · 1 comment

Comments

@chrisguttandin
Copy link
Contributor

Describe the bug

After enabling logging for notifications on stopped observables with config.onStoppedNotification I noticed that zip() sometimes throws an error which can't be delivered anymore in case the observable gets closed from within the next handler.

Firefox: TypeError: buffers is null
Chrome: TypeError: Cannot read properties of null (reading 'some')

The error originates from here:

if (buffers.some((buffer, i) => !buffer.length && completed[i])) {

Expected behavior

I would not expect this to happen. I think this case should be handled internally.

Reproduction code

import { NEVER, concat, config, first, of, zip } from 'rxjs';

config.onStoppedNotification = (notification) => {
  if (notification.kind === 'E') {
    throw notification.error;
  }
};

const source$ = concat(of(1), NEVER);

zip(source$).pipe(first()).subscribe();

Reproduction URL

https://stackblitz.com/edit/rxjs-qxrbts?devtoolsheight=60&file=index.ts

Version

7.4.0

Environment

I discovered this in an Angular App (v13.1) which also uses NgRx (v13) but I guess it's not relevant for this issue.

Additional context

I think adding a simple check if buffers is already null before calling buffers.some() should fix the issue. I would be happy to provide a PR with this fix.

@truebden
Copy link

truebden commented Jul 2, 2024

I just faced this issue in my code too and it would be great to have the PR merged 😉

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

No branches or pull requests

2 participants