Conversation
|
I should also point out that one can also |
|
Thanks for this @jpobley! I think that Could you please do a small modification and change this to: this.whenSynced = new Promise(..)
this.whenSynced.catch(err => { this.emit('error', ..) })Otherwise This issue is fairly preventable. The example should probably show that you only create a y-indexeddb provider when IndexedDB is supported and enabled. Not sure how one can check for that. |
548e2f6 to
42d751f
Compare
|
Cool. Updated. I wasn't entirely sure what you meant by your request, so lemme know if I misunderstood it.
Yeah, you'd think there would be a flag set or something, but I haven't found anything. One idea off the cuff might be updating import {uuidv4} from './random.js'
export const isEnabled = (function checkIdbEnabled() {
let idbEnabled;
const name = `lib0-idb-enabled-check-${uuidv4()}`;
const request = indexedDB.open(name)
request.onerror = e => idbEnabled = false
request.onsuccess = e => {
e.target.result.close()
indexedDB.deleteDatabase(name)
idbEnabled = true
}
return () => idbEnabled
})() |
| this.synced = true | ||
| return this | ||
| }) | ||
| this.whenSynced = promise.create((resolve, reject) => { |
There was a problem hiding this comment.
Ah, I guess I misunderstood your ask. Above, you requested this change:
this.whenSynced = new Promise(..)
this.whenSynced.catch(err => { this.emit('error', ..) })Which I interpreted to mean that you wanted this.whenSynced to be a new Promise instead of the Promise returned from this._db.
What would you like me to do instead?
There was a problem hiding this comment.
Ah, got it. Don't take my above comment too literally. The second part this.whenSynced.catch(err => { this.emit('error', ..) }) is fine. The first part adds five extra lines of code with no apparent benefit. Please rework the PR to include a minimal amount of changes.
Firefox Private Browsing disables IndexedDb by default, which causes an error. We need to catch and emit that error so clients using
IndexedDbProvidercan do something about it.It turns out there is a workaround, but if we don't catch the error, we can't suggest it.