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

Errors are squeltched when thrown in next, after any operator, while useDeprecatedSynchronousErrorHandling = true; #5979

Closed
benlesh opened this issue Jan 25, 2021 · 1 comment · Fixed by #5980
Assignees

Comments

@benlesh
Copy link
Member

benlesh commented Jan 25, 2021

In RxJS 7, if you set useDeprecatedSynchronousErrorHandling = true, and you have a source that uses any operator, when you throw an error in the next handler, it's not rethrown. The first example was with take, but I've confirmed it also happens with map, concatMap, and others.

https://stackblitz.com/edit/rxjs-fuauce?devtoolsheight=60

import { of, config } from "rxjs";
import { take } from "rxjs/operators";

console.clear();

config.useDeprecatedSynchronousErrorHandling = true;

try {
  of("test")
    .pipe(take(1))
    .subscribe({
      next: value => {
        console.log("value: ", value);
        throw new Error("test");
      }
    });
} catch (err) {
  // This is never hit in v7, but it is hit in v6.
  console.log("Caught!", err.message);
}

We'll need to check takeUntil, takeWhile, and first for the same issues.

cc @leggechr

@benlesh benlesh self-assigned this Jan 25, 2021
@benlesh benlesh changed the title Errors are squeltched when thrown in next, after take, while useDeprecatedSynchronousErrorHandling = true; Errors are squeltched when thrown in next, after any operator, while useDeprecatedSynchronousErrorHandling = true; Jan 25, 2021
@benlesh
Copy link
Member Author

benlesh commented Jan 25, 2021

The apparent cause is that the new architecture "knows" that we don't synchronously rethrow in the common case. So when the error is synchronously rethrown, it unwinds the stack and is caught by the try-catch blocks in the OperatorSubscriber. We'll unfortunately need to work around this for the deprecated case. :\

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.

1 participant