-
Notifications
You must be signed in to change notification settings - Fork 132
fix AbortController re-initialization (electric-db-collection) #523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix AbortController re-initialization (electric-db-collection) #523
Conversation
🦋 Changeset detectedLatest commit: 3c47b2a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
More templates
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
samwillis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, really well spotted.
I don't suppose you could try and create a test that reproduces the problem so we can validate this fix and prevent a regression in future?
KyleAMathews
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Could you add a test which reproduces the bug? Call cleanup & then query again to make sure sync starts up again?
|
Tomorrow I'll make these changes and write a test for it |
|
I'm pretty sure I've run into the same bug so thanks for figuring it out! |
|
A customer is running into this in production so I'm going to add a test to get this out. Thanks again for debugging things and putting up the PR!! |
|
Yeah if you can write the test since I tried multiple ways to write it but I don't know how to test this case.. cause the mock is done on a global |
b104472 to
94c3b77
Compare
|
Yeah, I couldn't get it to work either after trying for a bit — our mocks need modified quite a bit to make a test work. Let's merge and release. |
|
I deployed this to my app and confirmed it fixed the bug |
…ack#523) Co-authored-by: Kyle Mathews <mathews.kyle@gmail.com>
Hi! I debugged what was happening in #418 and finally I discovered the issue's cause.
The
AbortControllerinside the sync config ofelectric-db-collectionafter being aborted (by the cleanup fn after thegcTimeand 0 active subscribers) was never re-initialized again.And cause the signal was already
aborted, the electric client skips the sync request! (https://github.com/electric-sql/electric/blob/3baf67a11887fea0bd046b06e081a93f16c88173/packages/typescript-client/src/client.ts#L474)I only moved the AbortController instantiation inside the sync() function instead of the parent scope.