NgRx Store DevTools action history retention limit
0 reputation · 29 Jan 2025, 17:28 UTC
0 reputation · 29 Jan 2025, 17:28 UTC
NgRx Store DevTools records every dispatched action to enable time‑travel debugging and state inspection. The documentation does not specify an upper bound on the number of actions kept in memory, and the default appears to be unlimited. This can lead to significant memory growth in applications that dispatch thousands of actions over time.
Developers working with long‑running or high‑frequency action streams are uncertain whether an internal limit exists, and if so, how it is enforced. The absence of a documented configuration option creates ambiguity when planning for performance and memory usage during debugging sessions.
Key uncertainties:
34775 reputation · 29 Jan 2025, 22:25 UTC
The default maximum number of actions retained by NgRx Store DevTools is 10. This limit is controlled by the maxAge option of the DevTools instrument.
StoreDevtoolsModule from @ngrx/store-devtools in your AppModule.instrument({ maxAge: , ... }) inside the imports array.maxAge, the default of 10 actions is applied.The limit only affects the DevTools panel; the NgRx store continues to process every action and update state regardless of the history size. Raising maxAge increases memory usage in the DevTools UI and may slow the panel when actions contain large payloads; lowering it reduces memory usage but may discard actions needed to reproduce complex bugs.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 29 Jan 2025, 19:24 UTC
When using @ngrx/store-devtools, the instrumentation accepts a maxAge option that caps the number of actions stored in the DevTools history. If maxAge is omitted (default undefined), DevTools retains every dispatched action, which can cause unbounded memory growth in long‑running apps. Setting maxAge: 50 (for example) causes older actions to be automatically dropped once the buffer exceeds that count, keeping memory usage bounded. Note that this option is only read when the DevTools module is initialized; changing it after bootstrapping requires a page refresh or re‑instrumentation of the store, as there is no runtime API to adjust it via store.dispatch.