ITADN

firstValueFrom not matching documented behavior

#7538Closedjpage-godaddy 创建于 2025-03-11
J
jpage-godaddycommented
### Describe the bug According to the documentation for `firstValueFrom`: > If the observable stream completes before any values were emitted, the returned promise will reject with `EmptyError` or will resolve with the default value if a default was specified. However, with this line of code: ```typescript const match = await firstValueFrom( this.someStringObservable().pipe(find((g) => g === 'blah')), ); ``` ...the `match` value resolves to `undefined`; `EmptyError` is not thrown. ### Expected behavior `firstValueFrom` should either match the documented behavior or the documentation should be fixed. ### Reproduction code ```typescript const { from, firstValueFrom, find } = await import("rxjs"); const result = await firstValueFrom(from(['a', 'b', 'c']).pipe(find(x => x === 'd'))); console.log({ result }); ``` ### Reproduction URL _No response_ ### Version 7.8.1 ### Environment _No response_ ### Additional context _No response_
关闭于 2025-03-11 0 条评论