Skip to content

Collection: Prevent deep cloning and spread operator limits when creating allItems #9332

@tobiu

Description

@tobiu

When a Collection is filtered for the first time, it creates an allItems replica to store the unfiltered dataset:

me.allItems = me.createAllItems({
    // ...
    items: [...me._items],
    // ...
});

This causes two severe performance and memory issues for large datasets (e.g., 50k+ items in Turbo Mode):

  1. Spread Operator Limits: Spreading [...me._items] for massive arrays can hit browser engine limits (especially in Safari/Firefox) and cause stack overflows.
  2. Deep Cloning: Passing the massive items array directly into the config object causes Neo.core.Base to deeply clone all 50k items into this.originalConfig during instantiation. This takes multiple seconds and causes massive Garbage Collection pauses.

Fix:
Create the allItems collection without the items config to completely bypass the originalConfig deep clone. Then, use me._items.slice() (which avoids spread operator limits while safely shallow-copying) and inject the items via me.allItems.add(), which natively handles internal chunking and stack-overflow protections.

Metadata

Metadata

Assignees

Labels

aibugSomething isn't workingperformancePerformance improvements and optimizations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions