EmptyError Angular Origin: On your device Last updated 15 Oct 2026

RxJS: EmptyError: no elements in sequence (firstValueFrom / lastValueFrom on an empty Observable)

firstValueFrom, lastValueFrom, first() or last() waited for a value but the Observable completed without emitting.

Exact message you may see EmptyError: no elements in sequenceno elements in sequenceEmptyError: no elements in sequence firstValueFrom
Seen on: Angular TypeScript

Meaning

These helpers reject with EmptyError when the source completes empty (an empty array in from([]), a filter that dropped everything, an HTTP call returning EMPTY). Provide a default ({ defaultValue: null }), use take(1) with defaultIfEmpty, or handle the empty case explicitly.

Common causes

  • Source completed without emitting (filtered out, empty list, EMPTY)
  • firstValueFrom used on a Subject that completes first
  • first() after a filter that matches nothing
  • Error handling returning EMPTY
  • Route guard or resolver relying on a value that never arrives

⚡ Quick fix

  1. Pass a default: firstValueFrom(obs$, { defaultValue: null })
  2. Use defaultIfEmpty(null) before the helper
  3. Catch the error and handle emptiness

Detailed fix by platform

Angular

  1. const user = await firstValueFrom(user$.pipe(defaultIfEmpty(null)));
  2. Prefer take(1) without throwing on empty: user$.pipe(take(1)).subscribe(...)

Code examples

Safe first value

typescript
import { defaultIfEmpty, firstValueFrom } from 'rxjs';

const first = await firstValueFrom(this.items$.pipe(defaultIfEmpty(null)));   // null instead of EmptyError

How to diagnose

  1. Source — Does the Observable emit before completing?
  2. Operators — filter/EMPTY upstream?
  3. Helper — Is a default value provided?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Cannot find control with name — Angular: Error: Cannot find control with name: 'email' (reactive forms) (Angular)Cannot find control w…Could not find the builder's node package — Angular CLI: Could not find the '@angular-devkit/build-angular:browser' builder's node package / Cannot find module '@angular-devkit/build-angular/package.json' (Angular)Could not find the bu…exceeded maximum budget — Angular build: Error: bundle initial exceeded maximum budget. Budget 1.00 MB was not met by 120.00 kB with a total of 1.12 MB (Angular)exceeded maximum budg…NG02100 — Angular: NG02100: InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe' (Angular)NG02100Schema validation failed with the following errors — Angular CLI: Schema validation failed with the following errors: Data path "" must NOT have additional properties(xyz) (Angular)Schema validation fai…UnhandledPromiseRejection — Node.js: [UnhandledPromiseRejection] — This error originated either by throwing inside of an async function without a catch block (Node.js)UnhandledPromiseRejec…You provided 'undefined' where a stream was expected — RxJS: TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable. (Angular)You provided 'undefin…EmptyError

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.