The following code:
import { toObservable } from '@angular/core/rxjs-interop';
...
export class MyService {
readonly myData= signal<MyData| null>(null);
// toObservable creates a cold observable. Use startWith to make it function as a BehaviorSubject.
readonly myData$ = toObservable(this.myData).pipe(startWith(this.myData()));
Causes an error on ng build
:
X [ERROR] An error occurred while extracting routes
TypeError: r.notifier.notify is not a function
at ** (file:///C:/Users/**/.angular/prerender-root/**/chunk-**.mjs:34:86300)
....
I am not entirely sure how to move forward from this other than ditch the function toObservable
for now. It seems that it fails at prerendering or some other phase of the ng build
. The r.notifier.notify
is already internal to Angular and is beyond the scope of the application layer.
The following code:
import { toObservable } from '@angular/core/rxjs-interop';
...
export class MyService {
readonly myData= signal<MyData| null>(null);
// toObservable creates a cold observable. Use startWith to make it function as a BehaviorSubject.
readonly myData$ = toObservable(this.myData).pipe(startWith(this.myData()));
Causes an error on ng build
:
X [ERROR] An error occurred while extracting routes
TypeError: r.notifier.notify is not a function
at ** (file:///C:/Users/**/.angular/prerender-root/**/chunk-**.mjs:34:86300)
....
I am not entirely sure how to move forward from this other than ditch the function toObservable
for now. It seems that it fails at prerendering or some other phase of the ng build
. The r.notifier.notify
is already internal to Angular and is beyond the scope of the application layer.
1 Answer
Reset to default 1My guess is that you're injecting that service into an ErrorHandler
.
toObservable
is pulling effect
and is creating a cyclic dependency injection within Angular.
So the solution should be to somehow break that cyclic DI by delaying the injection of MyService
with a Injector.get(MyService)
instead.
On the framework side this issue should be addressed by 2 PRs:
- https://github/angular/angular/pull/58984 To instantiate the ErrorHandler lazily which would break the cyclic DI
- https://github/angular/angular/pull/60118 The Cyclic DI error should be thrown in prod mode
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745104760a4611490.html
.angular
-cache folder? – Silvermind Commented Mar 3 at 8:17