Tips for transferring errors from effects to actions within NGRX

Having recently delved into NGRX, I am attempting to transfer an error thrown in an effect to an action and store the error object. While this functionality appears to work smoothly on my local setup, it encounters an issue once deployed on the server:

Error: Detected unserializable action at "error". https://ngrx.io/guide/store/configuration/runtime-checks#strictactionserializability

The structure of my action is as follows:

export const loginFailed = createAction(
  "[Login dialog] User log in failed",
  props<{error : any}>()
);

Within my effect's catch statement:

catchError((error) => of(AuthActions.loginFailed({error : error})))

This situation raises several queries:

  • Why does this error only arise on the server and not during local testing?

  • What causes the "any" type for error to be non-serializable?

  • Are there more effective methods for transferring errors to the store?

I experimented with specifying the "Error" interface as the type for the error within the action props, yet encountered the same error.

In investigating ngrx documentation, I could not locate any resources pertaining to error objects or their management.

Answer №1

A specialized Issue object is an instance of a unique class that cannot be serialized. It is designed to function consistently across all systems, unless there are specific settings in your NgRx setup that alter this behavior.

For further details, please refer to the documentation:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing the TypeScript class property to be undefined?

Below is the code snippet I am working with: class FeedbackController { public homePage(req, res){ this.test(); res.send('Welcome to feedback service'); } private test(){ console.log('test called'); } } export de ...

How to assign ngModel to a nested component in Angular?

If I have a component called InputComponent, which implements the ControlValueAccessor interface. Now, another component named AnotherComponent uses the InputComponent like this: <my-input [(ngModel)]="text"></my-input> While testing AnotherC ...

Issue with rendering object in Three.js ply loader

Just starting out with three.js and Angular 13, using three.js v0.137.0. I'm attempting to load and preview a ply file from a data URL, but all I see after rendering is a bunch of lines, as shown in this screenshot - how the ply file renders. The .pl ...

Stop modal from closing in the presence of an error

My approach involves using a generic method where, upon adding a food item, a modal window with a form opens for the user to input their details. However, since backend validation for duplicate items can only be retrieved after the API call completes. I w ...

Instructions on declaring a Typescript variable that will only be assigned once in the future

In the land of coding, there are two constants: const which sets a value at declaration, and let which allows for variables to be changed. But what about a special Typescript (or javascript) variable that starts as undefined, and once defined, remains fo ...

What is the best way to eliminate square brackets from keys within an array of objects in TypeScript?

I am currently working on a task to eliminate all square brackets from the keys in the entries field within an array of objects: data: [ {title: "Title1", entries: { 'Entry1': 333333, '[ABC]Entry2': 1234, 'Entry3' ...

What is the best way to implement an EventHandler class using TypeScript?

I am in the process of migrating my project from JavaScript to TypeScript and encountering an issue with transitioning a class for managing events. To prevent duplicate option descriptions for adding/removing event listeners, we utilize a wrapper like thi ...

The correlation between a TypeScript class and an interface bearing an identical name

I have been struggling to find clear documentation or explanation for the unique relationship between a TypeScript class and an interface that share the same name. What is the significance of having an interface with the same name as a class? Why does a ...

Sluggish website loading time

Hey there, I'm currently developing a website and I'm facing a major issue with one of my pages loading slowly and experiencing lag. I'm unsure if this is due to the on scroll listeners or the excessive references in my code. Could it possib ...

Creating static files using an Angular 2 seed project

I am currently working on building an application with the help of Angular2-seed. While attempting to create a static demo, I encountered issues with some missing resources. Upon running npm run build.dev, the following files are generated in the project ...

Similar to [JsonPropertyName] in C#, but for TypeScript

Need help deserializing JSON response into a class defined in Angular. Let's use the example class below: export class ChatHubInfo { hubUrl: string = undefined! accessToken: string = undefined! } However, the JSON response is structured different ...

Leveraging React-Three-Fiber: A Guide to Implementing setViewOffset

Currently, I am incorporating React-Three-Fiber into a TypeScript application. I have successfully configured my canvas and camera, but I am struggling with implementing .setViewOffset on my orthographic camera. The official documentation for Three.js spec ...

Is there a way to display the items I've added to my cart when I click on it?

I have a collection of product IDs stored in local storage. I am using these IDs to populate the list of products added to the basket. Strangely, when I navigate to the basket page, the products do not appear unless I make a small code modification or re-s ...

Using React to iterate through the child components of the parent

I have created a component that can accept either a single child or multiple children. Here is an example with multiple children: <SideDataGridItem> <div id='top'> <div>A1</div> <div>B1</div> ...

What is the best way to sort a list with parent and child elements using Angular 2?

I have a tree structure in Angular 1 that allows me to filter the list at any level by typing in a textbox. Check out this demonstration to see it in action. Now, I am working on converting this functionality to Angular 2 and aiming for the desired output ...

Issue with Angular2 discount calculation formula malfunctioning

I'm encountering a rather perplexing issue with Angular2/Typescript. My goal is to compute the final price based on a specified discount value. Here's the formula I am using: row.priceList = row.pricePurchase + (row.pricePurchase * row.markUp / ...

Creating a CSV file by utilizing Azure Functions in Node.js

I have a task where I need to generate a csv file by extracting data from mongodb. The frontend of my application is built using Ionic (angular) and the backend is an Azure function developed in Node.js. My aim is to enable users to download this csv file ...

Infinite scrolling pagination feature in ag-grid not functioning properly with Angular

Upon the initial component load, all data appears as expected. However, when switching to the next page, the grid clears and an error is shown in the console: ERROR Error: ag-Grid: unable to draw rows while already drawing rows. It seems that a grid API ...

Setting the type of a prop dynamically based on another prop value

Consider the following scenario with an interface: interface Example { Component: React.ReactElement; componentProperties: typeof Example.Component; } Is there a way to determine the type of properties expected by a passed-in custom component? For ...

Sharing routes and controllers across ASP.NET and ASP.NET Core projects within a single solution

Query: What's the best way to integrate a .NET Core application with the controllers, routes, and authentication used by an ASP.NET application in the same project? Context: Currently, I have a single page application developed using the ASP.NET Sing ...