collectGroupBy() retains every value and rebuilds all groups on each emission
- Dominant language
- TypeScript
- Stars
- 29
- Forks
- 3
- Avg merge
- 3h 5m
- Merged PRs (30d)
- 11
Description
#70 removed the unbounded retention from `scanLatestEach()`, but `collectGroupBy()`
— which that implementation used to be built on — still has it
(`src/lib/stores/operators.ts:65-82`):
```ts
export function collectGroupBy(f: (a: A) => K): OperatorFunction> {
return pipe(
scanArray(),
map((xs) => {
const dict = new Map();
xs.forEach((x) => { ... dict.set(key, [...value, x]); ... });
return dict;
})
);
}
```
It retains every value it has ever seen via `scanArray()` and rebuilds the whole
grouping, copying each group, on every emission. Cost per value rises with the
length of the stream — the measurements in #70 were 79 ms at 1 000 values, 603 ms at
2 000 and 5 214 ms at 4 000.
Nothing inside the library uses it any more, but it is still exported from
`src/lib/stores/index.ts` as public API. A consumer applying it to a long-lived
forward-req stream reproduces exactly the bug #70 fixed.
Determined by code reading; the measurements are from #70.
## Direction
Remove it from the public API, or reimplement it to keep only what it emits.
Contributor guide
No contributing guide indexed for this repository
Research direction
Read src/lib/stores/operators.ts:65-82 and inspect the export in src/lib/stores/index.ts, then check whether any library code still uses collectGroupBy(). Compare the removal and reimplementation options against the retention and rebuild behavior described here; done means the public API no longer has the long-lived stream cost and the affected behavior is verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100