Skip to content

firstValueFrom not matching documented behavior #7538

Closed
@jpage-godaddy

Description

@jpage-godaddy

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:

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions