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

Async dispatched config handlers #7344

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented Sep 20, 2023

This is removing dependency on timeoutProvider in Observable because observable depends on Subscriber, and Subscriber users timeoutProvider for both onUnhandledError and onStoppedNotification, when it doesn't really need to. That's not particularly what timeoutProvider is for.

This also preps us to publish @rxjs/observable by limiting the dependencies that Observable has.

Resolves #7343

@benlesh benlesh force-pushed the async-dispatched-config-handlers branch from 29982fd to 4a30be8 Compare September 21, 2023 16:32
const sharedSource = source.pipe(share({ resetOnComplete: () => reset, resetOnRefCountZero }));

const result = concat(sharedSource, firstPause, sharedSource);
it('should not call "resetOnRefCountZero" on error', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything under this section is really a whitespace change. I'm not sure why the diff is flipping out here. This was just from reorganizing things in the file I think.

@@ -810,9 +797,22 @@ describe('share', () => {
});
});

it('should not reset on refCount 0 if reset notifier errors before emitting any value', () => {
spyOnUnhandledError((onUnhandledError) => {
describe('when config.onUnhandledError is set', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this describe block is what I think messed with the whitespace diff in other parts of the file.

@@ -856,89 +855,86 @@ describe('share', () => {
expectObservable(result, subscription).toBe(expected);
expectSubscriptions(source.subscriptions).toBe(sourceSubs);
});

expect(onUnhandledError).to.have.been.calledOnce;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests were errant, in that they were able to check to see if onUnhandledError was dispatched synchronously, which it was never supposed to be.

@benlesh benlesh marked this pull request as ready for review September 21, 2023 16:38
@@ -267,7 +266,7 @@ function createSafeObserver<T>(observerOrNext?: Partial<Observer<T>> | ((value:
*/
function handleStoppedNotification(notification: ObservableNotification<any>, subscriber: Subscriber<any>) {
const { onStoppedNotification } = config;
onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));
onStoppedNotification && setTimeout(() => onStoppedNotification(notification, subscriber));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One important bit is here.

@@ -11,7 +10,7 @@ import { timeoutProvider } from '../scheduler/timeoutProvider';
* @param err the error to report
*/
export function reportUnhandledError(err: any) {
timeoutProvider.setTimeout(() => {
setTimeout(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other important bit is here.

@benlesh benlesh merged commit 8b9d0ef into ReactiveX:master Oct 27, 2023
3 checks passed
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 this pull request may close these issues.

onStoppedNotification and onUnhandledError shouldn't be allowed to flip synchronous via provider delegates
2 participants