SetAsyncErrorAction fails when setting error object for second time
Closed this issue · 3 comments
I'm call endpoint from effect to do some validations, call looks like this.
return this.service.validate()
.pipe(
map((response): Action => {
if (response.hasError) {
return new SetAsyncErrorAction(FORM_CONTROL, VALIDATION_ID, response.errors)
}
return new ClearAsyncErrorAction(FORM_CONTROL, VALIDATION_ID)
}),
catchError(error => of(new SetAsyncErrorAction(FORM_CONTROL, VALIDATION_ID, error))),
startWith(new StartAsyncValidationAction(FORM_CONTROL, VALIDATION_ID))
)
When network connection is lost (in this example) catchError
is called and error is set with no issues. However if I make another call and receive error catchError
is called again and app crashes.
Are you intentionally storing your entire failed request "XMLHttpRequest" as error under form control? Seems strange why you need to do that.
If that's needed anyway, then deepEquals function has to be modified to take into account these advanced-access/restricted properties.
There is no actual need for my use case to store entire error object so I have modified it, however it should not crash the app if there is need for it.
Checking for such objects would be rather difficult. The general rule for ngrx is to only use safely serializable objects in actions and the store. Therefore, I won't provide a fix for this.