| 203 | const known = this.incarnation; |
| 204 | void this.adoptIncarnation(db).then(current => { |
| 205 | this.initInFlight = null; |
| 206 | // The marker read is asynchronous: this handle can close |
| 207 | // again before it finishes. Never announce a dead handle |
| 208 | // as recovered or erase the new connection-lost state. |
| 209 | if (closedDuringAdoption || this.db !== db || this.closedForVersionChange) { |
| 210 | const error = new Error(this.closedForVersionChange |
| 211 | ? 'Chat storage updated in another tab. Reload to continue.' |
| 212 | : 'Chat storage closed during recovery. Please try again.'); |
| 213 | if (this.connectionLost) { |
| 214 | this.reopenFailure = { at: Date.now(), error }; |
| 215 | if (!this.reconnectFailureReported) { |
| 216 | this.reconnectFailureReported = true; |
| 217 | this.dispatchWindowEvent('oa-db-reconnect-failed'); |
| 218 | } |
| 219 | } |