You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// there's another open connection to same database
144
-
// and it wasn't closed by db.onversionchange listener
144
+
// and it wasn't closed after db.onversionchange triggered for them
145
145
};
146
146
*/!*
147
147
```
148
148
149
149
We do two things:
150
150
151
151
1. Add `db.onversionchange` listener after a successful opening, to close the old database.
152
-
2. Add `openRequest.onblocked` listener to handle the case when an old connection wasn't closed. Normally, this doesn't happen if we close it in `db.onversionchange`.
152
+
2. Add `openRequest.onblocked` listener to handle the case when an old connection wasn't closed. This doesn't happen if we close it in `db.onversionchange`.
153
153
154
-
Alternatively, we can just do nothing in `db.onversionchange` and let the new connection be blocked with a proper message. That's up to us really.
154
+
Alternatively, we can take time to close things gracefully in `db.onversionchange`, prompt the visitor to do something. The new connection will be blocked immediatelly after `db.onversionchange` finished without closing, but we can try to reopen it later.
155
+
156
+
That's up to us, how we handle such version collision, it happens rarely, but we should at least have some handling for it, e.g. `onblocked` handler, so that our script doesn't just die silently.
0 commit comments