()
| 97 | |
| 98 | // Commit callback that the strategy will call when it's time to persist |
| 99 | const commitCallback = () => { |
| 100 | if (!activeTransaction) { |
| 101 | throw new Error( |
| 102 | `Strategy callback called but no active transaction exists. This indicates a bug in the strategy implementation.`, |
| 103 | ) |
| 104 | } |
| 105 | |
| 106 | if (activeTransaction.state !== `pending`) { |
| 107 | throw new Error( |
| 108 | `Strategy callback called but active transaction is in state "${activeTransaction.state}". Expected "pending".`, |
| 109 | ) |
| 110 | } |
| 111 | |
| 112 | const txToCommit = activeTransaction |
| 113 | |
| 114 | // Clear active transaction reference before committing |
| 115 | activeTransaction = null |
| 116 | |
| 117 | // Commit the transaction |
| 118 | txToCommit.commit().catch(() => { |
| 119 | // Errors are handled via transaction.isPersisted.promise |
| 120 | // This catch prevents unhandled promise rejections |
| 121 | }) |
| 122 | |
| 123 | return txToCommit |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Executes a mutation with the given variables. Creates a new transaction if none is active, |
no test coverage detected