rxjs icon indicating copy to clipboard operation
rxjs copied to clipboard

Chore/config handler spies test helpers

Open backbone87 opened this issue 4 years ago • 6 comments

Description:

I introduced a helper function in https://github.com/ReactiveX/rxjs/pull/6169/files#diff-9e451a38948f76e3294d51d3a213e0e9d0170c3d327a871e1435a457a8268125R28 to more easily test the global config handlers.

With this PR I want to extract it into a general helper function in helpers/test-helper and convert existing config tests (or other tests involving the global config handlers) to use the helper. This also makes the config tests more readable imho, because the code order now matches the execution order.

I also removed a duplicated test in Observable-spec.ts which had the same test code as one of the config-spec tests.

BREAKING CHANGE: While implementing the helper and converting the config-spec tests, I noticed a small discrepancy between how onUnhandledError and onStoppedNotification are handled. In the last commit, I adjusted onUnhandledError handling to match that of onStoppedNotification and added appropriate tests. this might be considered a BC break in the following case:

// current behavior
config.onUnhandledError = () => console.log('I am not called.');

new Observable((subscriber) => {
  subscriber.error('bad');
}).subscribe();

config.onUnhandledError = () => console.log('But I am!');

// behavior after the change
config.onUnhandledError = () => console.log('I am called!');

new Observable((subscriber) => {
  subscriber.error('bad');
}).subscribe();

config.onUnhandledError = () => console.log('But I am not.');

backbone87 avatar May 29 '21 15:05 backbone87

added one more test case for the execution order of onUnhandledError & onStoppedNotification

backbone87 avatar May 29 '21 18:05 backbone87

Thank you for this pr @backbone87. I'm going to add this to the Core Team agenda so we can decide which behavior is appropriate. While it might be a breaking change for someone, I think I personally see this as a bug fix, and it might be worth introducing in a patch. These features aren't very broadly used yet, to my knowledge. Particularly in this edge case.

benlesh avatar Aug 05 '21 15:08 benlesh

rebased against master

backbone87 avatar Aug 07 '21 11:08 backbone87

Core Team: No quorum! Saving for next core team meeting.

benlesh avatar Aug 11 '21 20:08 benlesh

Core Team meeting again: Punting. Not enough for quorum

benlesh avatar Sep 22 '21 20:09 benlesh

Core Team: This is a bug fix and not a breaking change. We don't want people to "know" that the error is being handling asynchronously if it was synchronously thrown, the change to the handler shouldn't be honored. This may also help set us up for reportError usage. Related: #6795

benlesh avatar Mar 23 '22 20:03 benlesh

I'm so sorry, @backbone87 ... but this PR has a lot going on in it, and it's been so long since I looked at it, that I'm going to close it for now, in favor handling the identified bug in another PR.

benlesh avatar Dec 03 '22 18:12 benlesh