Bug: Mutable mapper parameters cause silent data inconsistencies
Version: @skipruntime/core@0.0.19
Problem
When passing arrays (or other mutable objects) as constructor parameters to Mapper implementations, the reactive graph produces subtle, hard-to-debug data inconsistencies. There is no error, no warning, and no documentation of this requirement.
Reproduction
class PhotoVisibilityFilter implements Mapper<string, Photo, string, Photo> {
constructor(
private userId: string,
private groupIds: string[] // mutable array
) {}
mapEntry(key: string, values: Values<Photo>): Iterable<[string, Photo]> {
const photo = values.getUnique();
if (this.groupIds.includes(photo.groupId)) {
return [[key, photo]];
}
return [];
}
}
// Later, when instantiating:
const groupIds = ["group-1", "group-2"];
// This SILENTLY causes issues — groupIds is mutable
const filtered = collection.map(PhotoVisibilityFilter, userId, groupIds);
Impact
- Manifests as intermittent, non-deterministic data inconsistencies in the reactive graph
- Extremely difficult to debug — no error message points to mutability as the cause
- Discovered only through trial and error after ruling out other possible causes
Current workaround
Freezing all array/object parameters before passing them to mappers:
const groupIds = Object.freeze(["group-1", "group-2"]);
const filtered = collection.map(PhotoVisibilityFilter, userId, groupIds);
And marking the types as readonly to prevent accidental mutation:
class PhotoVisibilityFilter implements Mapper<string, Photo, string, Photo> {
constructor(
private userId: string,
private groupIds: readonly string[]
) {}
// ...
}
Expected behavior
One of:
- Auto-freeze parameters internally when they are captured by the reactive graph
- Throw a clear error at construction time if mutable objects are passed as mapper parameters (e.g.,
TypeError: Mapper parameters must be frozen — call Object.freeze() on arrays/objects before passing them)
- Document the requirement prominently in the Mapper API docs with examples
Option 1 or 2 would be strongly preferred over documentation alone, since the failure mode is completely silent.
Bug: Mutable mapper parameters cause silent data inconsistencies
Version:
@skipruntime/core@0.0.19Problem
When passing arrays (or other mutable objects) as constructor parameters to
Mapperimplementations, the reactive graph produces subtle, hard-to-debug data inconsistencies. There is no error, no warning, and no documentation of this requirement.Reproduction
Impact
Current workaround
Freezing all array/object parameters before passing them to mappers:
And marking the types as
readonlyto prevent accidental mutation:Expected behavior
One of:
TypeError: Mapper parameters must be frozen — call Object.freeze() on arrays/objects before passing them)Option 1 or 2 would be strongly preferred over documentation alone, since the failure mode is completely silent.