rxjs
rxjs copied to clipboard
replace UnobservableError "invalid object" with object type
Description:
My application was crashing with the following generic error.
You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, AsyncIterable, or Iterable.
Upon closer inspection, I discovered that the object was indeed an Observable
. The underlying issue was that multiple versions of rxjs
were installed in my application. Once I was able to see that the "invalid object" was an "Observable", I knew immediately to audit node_modules
for this issue. I'm hopeful that providing additional information about this runtime error will help others.
Related issue (if exists):
None that I could find.
I've been thinking about this, and we may want to start having error numbers and documentation links with more concise messages overall. We have to ship all of this code, after all.
Something like RX0001 - object unobservable https://rxjs.dev/errors#RX0001
or RX0002 - Foreign observable https://rxjs.dev/errors#RX0002
and so on, where we can provide detailed information about what that error means, why it's happening, and how to solve it.
Core Team:
- Not sure if this provides a ton more value than what we have.
- People usually want to know where the returned thing was created or returned that didn't get converted to an observable.
There is an interesting proposal from 2014 by @stefanpenner brought to my attention by @ladyleet today: https://bugs.chromium.org/p/chromium/issues/detail?id=332624
Something like that might help get better context as to where something came from.
(BTW: Sorry @abacaphiliac for super late re-review)
CORE TEAM: We can get this in v8 maybe. It doesn't save the world, but maybe it will help someone? 🤷♂️