Chandler
Chandler•10mo ago

Deployed Marimo Failed to Instantiate Errors

Welp, hopefully this one is an actual issue, not just a typo 😅 Running my docker container on Fly.io and getting some pretty frequent failures to load the app/notebook. Poking through source on github that the stack trace pointed to, and it looks like it's expecting there to be no session, but there is one
# The session already exists, but it was disconnected.
# This can happen in local development when the client
# goes to sleep and wakes later. Just replace the session's
# socket, but keep its kernel
existing_session = mgr.get_session(session_id)
if existing_session is not None:
LOGGER.debug("Reconnecting session %s", session_id)
await self._reconnect_session(existing_session, replay=False)
return existing_session
# The session already exists, but it was disconnected.
# This can happen in local development when the client
# goes to sleep and wakes later. Just replace the session's
# socket, but keep its kernel
existing_session = mgr.get_session(session_id)
if existing_session is not None:
LOGGER.debug("Reconnecting session %s", session_id)
await self._reconnect_session(existing_session, replay=False)
return existing_session
Interestingly, one way this manifests is the browser gets stuck, never loads the app, and spams the /ws endpoint (see screenshot) I've seen other instances where it pops up saying "failed to instantiate"
8 Replies
Chandler
ChandlerOP•10mo ago
Here's the screenshot:
Chandler
ChandlerOP•10mo ago
No description
Chandler
ChandlerOP•10mo ago
Getting a 401 when it shows up with the Failed to instantiate error
No description
No description
Myles Scolnick
Myles Scolnick•10mo ago
You likely have 2 instances on fly running at the same time. marimo doesn't support multi-instance out of the box (since it hold state and need a bit more complicated infra there). If you drop your instance count to 1, it should fix the issue
egnor
egnor•10mo ago
Multi instance meaning: two Marimo kernels running within the same origin (scheme+host+port)? OR are you talking about multiple Marimo kernels running in one fly.io VM?? (I don't have my head wrapped around fly.io's like-Docker-but-not-Docker container runtime model)
Myles Scolnick
Myles Scolnick•10mo ago
The former. Fly will launch two instances by default and route randomly to one of them. Should be viewable in the fly dashboard
Chandler
ChandlerOP•10mo ago
Ah, gotcha. That's almost certainly it. Thank you for the response. Might i suggest adding a quick callout to the docker deployment page in the docs to use a single instance? Also, definitely no need for this for now, but I imagine that sticky sessions on the proxy/load balancer might mitigate this if I understand the limitation correctly? If that's true, I guess it might be worth mentioning that in the docs too, though I don't expect many people are sending enough traffic to Marimo to really justify horizontal scaling. I just imagine it would be useful for availability/failure recovery
Myles Scolnick
Myles Scolnick•10mo ago
Yea both good suggestions to add. We can add that