Describe the bug
I'm experiencing an issue with awaiting multiple txids in an electric collection mutation handler. I'm getting a TimeoutWaitingForTxIdError as soon as one of the txids are seen on the stream, even though I'm well below the timeout.
To Reproduce
Define a collection like this:
consttodosCollection=createCollection(electricCollectionOptions({id: 'todos',getKey: (item)=>item.id,shapeOptions: {url: '/api/todos',params: {table: 'todos'},},onInsert: async({ transaction })=>{consttxids=awaitPromise.all(transaction.mutations.map((mutation)=>api.todos.create(mutation.modified),));return{txid: txids};}}))Run a mutation (single or multiple entries):
// ❌ Throws TimeoutWaitingForTxIdError before 5 second timeouttodosCollection.insert({id: crypto.randomUUID(),title: 'New todo'})// ❌ Throws TimeoutWaitingForTxIdError before 5 second timeouttodosCollection.insert([{id: crypto.randomUUID(),title: 'New todo 1'},{id: crypto.randomUUID(),title: 'New todo 2'}])Expected behavior
I expect the mutations not to throw TimeoutWaitingForTxIdError unless the transaction takes > 5 seconds to appear on stream.
Desktop (please complete the following information):
- OS: MacOS
- Browser: Chrome
- Version: 141.0.7390.123
Additional context
The waiting works fine when returning a single txid instead of a txid array in mutation handler.
This modification to processMatchingStrategy fixes the issue:
await Promise.all(result.txid.map((txid) => awaitTxId(txid)))
Describe the bug
I'm experiencing an issue with awaiting multiple txids in an electric collection mutation handler. I'm getting a
TimeoutWaitingForTxIdErroras soon as one of the txids are seen on the stream, even though I'm well below the timeout.To Reproduce
Define a collection like this:
Run a mutation (single or multiple entries):
Expected behavior
I expect the mutations not to throw
TimeoutWaitingForTxIdErrorunless the transaction takes > 5 seconds to appear on stream.Desktop (please complete the following information):
Additional context
The waiting works fine when returning a single txid instead of a txid array in mutation handler.
This modification to processMatchingStrategy fixes the issue: