Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4014e19

Browse files
authored
fix: catch within innerSubscribe (#6186)
* test: add failing invalid ObservableInput tests* fix: catch within innerSubscribeCloses#5344
1 parent02219cc commit4014e19

File tree

5 files changed

+59
-1
lines changed

5 files changed

+59
-1
lines changed

‎spec/operators/concatMap-spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,4 +691,17 @@ describe('Observable.prototype.concatMap', () => {
691691
done(newError('Subscriber complete handler not supposed to be called.'));
692692
});
693693
});
694+
695+
it('should report invalid observable inputs via error notifications',()=>{
696+
conste1=hot('--1|');
697+
conste1subs='^ !';
698+
constexpected='--#';
699+
700+
constresult=e1.pipe(concatMap(()=>nullasany));
701+
702+
expectObservable(result).toBe(expected,null,newTypeError(
703+
"You provided 'null' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable."
704+
));
705+
expectSubscriptions(e1.subscriptions).toBe(e1subs);
706+
});
694707
});

‎spec/operators/exhaustMap-spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,17 @@ describe('exhaustMap', () => {
434434
expectSubscriptions(x.subscriptions).toBe(xsubs);
435435
expectSubscriptions(e1.subscriptions).toBe(e1subs);
436436
});
437+
438+
it('should report invalid observable inputs via error notifications',()=>{
439+
conste1=hot('--1|');
440+
conste1subs='^ !';
441+
constexpected='--#';
442+
443+
constresult=e1.pipe(exhaustMap(()=>nullasany));
444+
445+
expectObservable(result).toBe(expected,null,newTypeError(
446+
"You provided 'null' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable."
447+
));
448+
expectSubscriptions(e1.subscriptions).toBe(e1subs);
449+
});
437450
});

‎spec/operators/mergeMap-spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,4 +852,17 @@ describe('mergeMap', () => {
852852
expectObservable(result).toBe(expected,undefined,noXError);
853853
});
854854
});
855+
856+
it('should report invalid observable inputs via error notifications',()=>{
857+
conste1=hot('--1|');
858+
conste1subs='^ !';
859+
constexpected='--#';
860+
861+
constresult=e1.pipe(mergeMap(()=>nullasany));
862+
863+
expectObservable(result).toBe(expected,null,newTypeError(
864+
"You provided 'null' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable."
865+
));
866+
expectSubscriptions(e1.subscriptions).toBe(e1subs);
867+
});
855868
});

‎spec/operators/switchMap-spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,17 @@ describe('switchMap', () => {
444444
expectSubscriptions(x.subscriptions).toBe(xsubs);
445445
expectSubscriptions(e1.subscriptions).toBe(e1subs);
446446
});
447+
448+
it('should report invalid observable inputs via error notifications',()=>{
449+
conste1=hot('--1|');
450+
conste1subs='^ !';
451+
constexpected='--#';
452+
453+
constresult=e1.pipe(switchMap(()=>nullasany));
454+
455+
expectObservable(result).toBe(expected,null,newTypeError(
456+
"You provided 'null' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable."
457+
));
458+
expectSubscriptions(e1.subscriptions).toBe(e1subs);
459+
});
447460
});

‎src/internal/innerSubscribe.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,11 @@ export function innerSubscribe(result: any, innerSubscriber: Subscriber<any>): S
110110
if(resultinstanceofObservable){
111111
returnresult.subscribe(innerSubscriber);
112112
}
113-
returnsubscribeTo(result)(innerSubscriber)asSubscription;
113+
letsubscription:Subscription;
114+
try{
115+
subscription=subscribeTo(result)(innerSubscriber)asSubscription;
116+
}catch(error){
117+
innerSubscriber.error(error);
118+
}
119+
returnsubscription;
114120
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp