Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Gotcha with ReactiveSet/Map iterators

Open
#830 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
frontend

Research direction

Start at packages/map/src/index.ts lines 49-55 and compare the ReactiveSet/Map iterator methods with the linked SvelteSet and Map implementations. Use the StackBlitz reproduction to verify that calling values(), keys(), or items() without consuming the iterator registers tracking; done means changes trigger the asynchronous effect as intended.

Written by the indexing model from the issue text.

Description

help wanted
Describe the bug

Using .keys(), .values() or .items() on a ReactiveSet or ReactiveMap is meant to track all keys/values for changes. However, if the iterators are not consumed, then no tracking is registered.

This comes up when trying to declare dependencies of an asynchronous effect beforehand.

createEffect(() => {
  // Track set for changes
  void set.values();

  setTimeout(() => /* Use set contents... */);
});

Though the intention was to track the full content of the set, the above effect is not actually triggered by changes to the set.


The reason this happens is that the methods are implemented as generators like so:

https://github.com/solidjs-community/solid-primitives/blob/507ff661656cd51e3c280d0776054f487f0507de/packages/map/src/index.ts#L49-L55

The beginning of the method is not run until .next() is called for the first time.

I think the methods should not be generators themselves, rather just return super.values(). That would probably be more performant as well. SvelteSet & Map are implemented like this.

Happy to to write a PR if there is agreement.

Minimal Reproduction Link

https://stackblitz.com/edit/github-r2lfqdu4?file=src%2FApp.tsx

Dominant language
TypeScript
Stars
1.6k
Forks
165
Avg merge
12h 35m
Merged PRs (30d)
14

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from solidjs-community/solid-primitives

All issues in solidjs-community/solid-primitives

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.