collectGroupBy() retains every value and rebuilds all groups on each emission
- Langage dominant
- TypeScript
- Étoiles
- 29
- Forks
- 3
- Merge moyen
- 3 h 5 min
- PR mergées (30 j)
- 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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- frontend
- Type d'issue
- Bug
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 48/100