Skip to content

bug: strange mounting behavior near the stack limit#3294

Open
dmaskasky wants to merge 1 commit intopmndrs:mainfrom
dmaskasky:strange-mounted-behavior
Open

bug: strange mounting behavior near the stack limit#3294
dmaskasky wants to merge 1 commit intopmndrs:mainfrom
dmaskasky:strange-mounted-behavior

Conversation

@dmaskasky
Copy link
Copy Markdown
Collaborator

@dmaskasky dmaskasky commented Apr 2, 2026

Summary

I encountered a strange behavior when mounting a long chain of atoms. I am able to reliably reproduce this locally and in CI.

When mounting the leaf atom of a long chain of atoms (>996), only 996 atoms are mounted. Testing locally I got this result:

 FAIL   jotai  tests/vanilla/internals.test.tsx > internals > every dependency (deep) should be mounted
AssertionError: expected 996 to be 7548 // Object.is equality

- Expected
+ Received

- 7548
+ 996

 ❯ tests/vanilla/internals.test.tsx:33:29
     31|     const leaf = chain[chain.length - 1]!
     32|     store.sub(leaf, () => {})
     33|     expect(mountedMap.size).toBe(depth)
       |                             ^
     34|   })
     35| 

Why are only 996 atoms mounted?
Why are there no error throw / reported?

Check List

  • pnpm run fix for formatting and linting code and docs

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
jotai Ready Ready Preview, Comment Apr 2, 2026 2:52am

Request Review

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Apr 2, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

More templates

npm i https://pkg.pr.new/jotai@3294

commit: 25608bf

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

LiveCodes Preview in LiveCodes

Latest commit: 25608bf
Last updated: Apr 2, 2026 2:51am (UTC)

Playground Link
React demo https://livecodes.io?x=id/8N2FB5KLA

See documentations for usage instructions.

@dmaskasky dmaskasky force-pushed the strange-mounted-behavior branch from 87af485 to 25608bf Compare April 2, 2026 02:51
@dmaskasky dmaskasky requested a review from dai-shi April 3, 2026 06:33
@dmaskasky dmaskasky changed the title strange mounting behavior near the stack limit bug: strange mounting behavior near the stack limit Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant