While migrating from toPromise() to firstValueFrom/lastValueFrom due to the deprecation, I've run into an issue. Neither firstValueFrom/lastValueFrom works while toPromise() works as expected. The example code below shows my usecase. Neither of the 3 promises resolves on next(), while firstValueFrom should. Only toPromise() resolves on complete, while all 3 should. In the end the firstValueFrom/lastValueFrom produces EmptyError.
const subject = new Subject<boolean>();
setTimeout(async () => {
await subject.toPromise();
console.log("subject toPromise finished");
});
setTimeout(async () => {
await firstValueFrom(subject);
console.log("subject firstValueFrom finished");
});
setTimeout(async () => {
await lastValueFrom(subject);
console.log("subject lastValueFrom finished");
});
subject.next(true);
subject.complete();