T
TanStack•2w ago
stormy-gold

Collections sometimes get "stuck"

I apologize in advance for this pretty vague-sounding question. First off I've read the docs section on error handling but I'm not sure they apply here. When I observe the network tab in the console I can see the effect of the window gaining visibility because my collection(s) connection(s) ends with NS_BINDING_ABORTED and a new one starts. It seems that when this happens enough times, or I leave the tab for long enough (not sure which), this stops and my collection becomes stuck. I can no longer see new connections being made in the network tab. Doing something on the site (like sending a new message, which should be returned by a messages collection) confirms this - it doesn't show up until I refresh. I feel like I must have set something up wrong somewhere, but I'm not sure what. I'm using the Electric SQL API proxy approach as described in the docs. What is the expected long-running behavior of a collection (in this case Electric SQL)? Should it "time out" like this and/or should it automatically reconnect if it does?
10 Replies
stormy-gold
stormy-goldOP•2w ago
I just tried to recreate the issue and realized I can make it happen quite quickly (ie 5 sec or so) if I just switch between my tab and another one in quick succession. only on firefox (of course) yeah it really does seem to just be firefox when I go back and forth between tabs too quickly (maybe also when I leave it open too long but I'm having a hard time testing that)
foreign-sapphire
foreign-sapphire•2w ago
broad-brown
broad-brown•2w ago
@aneidon thanks for the bug report. I had a look at @Kyle Mathews's PR and i believe that fixes the issue. If you want you can checkout the PR and build the typescript client to try it out.
stormy-gold
stormy-goldOP•2w ago
thanks, that was quick! I'm just trying to give it a shot - Claude said I should be able to do
"@electric-sql/client": "github:electric-sql/electric#claude/investigate-collection-stuck-bug-011CV6HmgS6rMVU2QCTMVKys&path:/packages/typescript-client",
"@electric-sql/client": "github:electric-sql/electric#claude/investigate-collection-stuck-bug-011CV6HmgS6rMVU2QCTMVKys&path:/packages/typescript-client",
in my package.json, which does .. something?
> pnpm why -r @electric-sql/client
Legend: production dependency, optional only, dev only

frontend /Users/proever/Developer/personal/frontend (PRIVATE)

dependencies:
@electric-sql/client 1.1.3
@tanstack/electric-db-collection 0.1.40
└── @electric-sql/client 1.1.3
> pnpm why -r @electric-sql/client
Legend: production dependency, optional only, dev only

frontend /Users/proever/Developer/personal/frontend (PRIVATE)

dependencies:
@electric-sql/client 1.1.3
@tanstack/electric-db-collection 0.1.40
└── @electric-sql/client 1.1.3
I'm not sure that worked. Do I need to clone it and build it locally and reference that path? I'm not quite familiar enough with the ecosystem to understand how it works when a dependency I have is also pulled in by another one --- for reference here were my package versions
catalog:
'@electric-sql/client': ^1.1.1
'@tanstack/electric-db-collection': ^0.1.40
'@tanstack/react-db': ^0.1.38
'@tanstack/react-devtools': ^0.7.7
'@tanstack/react-query': ^5.90.6
'@tanstack/react-query-devtools': ^5.90.2
'@tanstack/react-router-devtools': ^1.134.9
"@tanstack/react-router": "^1.134.9",
"@tanstack/react-router-ssr-query": "^1.134.9",
"@tanstack/react-start": "^1.134.9",
catalog:
'@electric-sql/client': ^1.1.1
'@tanstack/electric-db-collection': ^0.1.40
'@tanstack/react-db': ^0.1.38
'@tanstack/react-devtools': ^0.7.7
'@tanstack/react-query': ^5.90.6
'@tanstack/react-query-devtools': ^5.90.2
'@tanstack/react-router-devtools': ^1.134.9
"@tanstack/react-router": "^1.134.9",
"@tanstack/react-router-ssr-query": "^1.134.9",
"@tanstack/react-start": "^1.134.9",
foreign-sapphire
foreign-sapphire•2w ago
we're pretty confident in the fix so will release it soon
broad-brown
broad-brown•2w ago
Yeah, i'm also adding preview packages. So you should be able to install the preview package soon if you want to test it šŸ™‚
stormy-gold
stormy-goldOP•2w ago
great, thank you both!
stormy-gold
stormy-goldOP•2w ago
all I managed to do trying to test it was get this other error that I have seen once before where the container gets in a state it can't seem to recover from: https://github.com/electric-sql/electric/issues/3433
GitHub
Container error: Stack not ready after 5000ms. Reason: Timeout wait...
Versions Client: ts 1.1.3 via tanstack DB Electric: 1.2.3 - docker Bug description The Electric SQL container gets stuck in an unrecoverable error state [warning] Stack not ready after 5000ms. Reas...
stormy-gold
stormy-goldOP•2w ago
I built from main and can confirm it seems fixed
foreign-sapphire
foreign-sapphire•2w ago
Thanks for confirming!

Did you find this page helpful?