Skip to content

Commit fbac9e9

Browse files
committed
minor
1 parent a808537 commit fbac9e9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

6-data-storage/03-indexeddb/article.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,19 @@ openRequest.onsuccess = function() {
141141
*!*
142142
openRequest.onblocked = function() {
143143
// 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
145145
};
146146
*/!*
147147
```
148148

149149
We do two things:
150150

151151
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`.
153153

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.
155157

156158
## Object store
157159

0 commit comments

Comments
 (0)