Charm + ReadonlyMap Issue: forEach shows data but get() returns nil for same userId in atom sub
I'm having a weird issue with Charm in my RBXTS project on Roblox. I'm using an atom that holds a
ReadonlyMap<number, PlayerData> for player states (where keys are UserIds as numbers). When a player joins, they're added to the map during hydration (I'm using charm-sync + tether), and I can see their initial state on the client-side (e.g., afk: false).
After about 2 seconds, I update the local player's afk to true by creating a new map immutably and setting the atom.
In my subscribe callback, I iterate over the state with forEach, and it correctly prints all entries, including my local UserId with the updated afk: true. However, in the same callback, when I manually do state.get(localPlayer.UserId), it returns nil every time; even though the UserId matches exactly what's shown in the iteration.
Here's the relevant code:
Output (before update):
Output (after update):The playerState is updated immutably like this: This is definitely being dispatched to the client, hence I made a debug message for incoming updates from the client syncer: LocalPlayer is fully loaded (this is post-join), and UserId is a number (no string conversion issues that I can see). Iteration works fine, so the entry exists, but
get() on ReadOnlyMap<K,V> fails. Is this a bug with ReadonlyMap, Charm's atom behavior, or something in rbxts? Any ideas?11 Replies
you manually fetch data on client or on server?
Right after the server sent the client the patched atom, on the client, I'm fetching the userId from the Map in the subscription callback. Basically
playerState changes on Server <=> synchronization <=> on client: subscribe(playerState, (map) => { .. })
and when the subscribe callback is called, it shows me the updated map, but I can't invoke
get(userId) with the same userId I also iterated oncan you give the code files?
hey, sorry for no response, because I haven't had the time to be active for few days. Recently, I just gone through some checks, and found out, that my atom has probably changed its type during runtime?

this is so strange
I assume, the serializer turns every number into a string, and my syncer on the client-side is turning my
Atom<ReadonlyMap<number, PlayerData>> into a Atom<ReadonlyMap<string, PlayerData>> during runtime.here's how I'm syncing the client


try using the debug middleware
please also show your message types
i want to rule out tether/serio being the issue
this seems good to me
oh yeah this is 100% the issue
not sure if this is a user error on my part or this is a flamework issue
yeah cause this was an issue i was dealing with in the past while making tether


@Fireboltofdeath i hate this was there a reason it does this cause i cant remember
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View
so evilllllllllllllllllllllllllllllllllll