-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
You provided an invalid object where a stream was expected error in Module Federation environment #6628
Comments
This sounds like somewhat similar to other enviroment which crosses boundary such as worker, IPC, etcs than our instance check fails. We didn't actively investigate to support webpack's module federation and do not have deep understanding around those yet. When webpack loads federated modules, does it properly passes over instance context across different modules? or otherwise, what exact observable object is being passed? if latter and if object is not proper instance of observable, what's webpack's contract for passing object across federated module? I think figure out those would be helpful, and depends on how webpack treats object we may, or may not resolve problems on our end. For example, if webpack's federated module enforces to break some of core contract of observable (we expect to preserve our instance as-is, reason we do not gaurantee pass observabe across worker thread / processes, etcs) it'll be not easy to resolve without webpack's help. |
But in any case, reproducible minimal example is strongly required to check futher. |
I try to reproduce the error by the following code, However I fail. Can you suggest an alternative?
` |
@dragonflypl were you ever able to identify what was the problem or a workaround that isn't removing switchMap? We are getting the same error in a micro-frontend context with Module Federation, but we started getting the error after we added a third-party script, so we're not sure if it's exactly the same problem, but apart from the third-party script part your problem is exactly the same. |
@ibis7 it was long time ago, but as far as I remember, the issue was that operators code was not shared, e.g. one place imported |
Bug Report
Current Behavior
switchMap
(and other mapping operators) might not work correctly in Module Federation environment.Code like:
Will cause :
You provided an invalid object where a stream was expected error in Module Federation environment
exceptionExpected behavior
Mapping operators should work and recognise
Reproduction
I was not able yet to reproduce it with a repo I could publicly push. This is explanation from the app I'm maintaining.
I've migrated one app to MFE Architecture using Module Federation and mysteriously looking error is thrown at runtime:
You provided an invalid object where a stream was expected error. You can provide an Observable, Promise, Array, or Iterable
.The code that causes it looks like this:
However I was pretty sure code was ok...
When analysing stack trace, error originates from:
In my case,
result
is of typeBehaviorSubject
.However, when I compared stack trace when app is running in non-federated to federated, the issue is here:
Without module federation, this
if
is truthy, when I look at prototypes, deeper I can findObservable
.However in federated environment, this expression is falsy.
The good news it that refactoring to:
does not throw error any more.
Environment
The text was updated successfully, but these errors were encountered: