don't wait if idb is blocked, remove workerize-loader (#602)

There are two issues here:

- if IDB is blocked, then the promise never resolves when you log out (and call indexedDB.deleteDatabase) and the app remains in a permanently hung state
- why is IDB blocked? well, something seems to have changed in Chrome 70 such that doing these operations in a web worker causes the blocked error. The benefits of workerizing IDB is so small that I'd rather just remove it at this point.
This commit is contained in:
Nolan Lawson 2018-11-03 17:06:01 -07:00
parent c305a9827a
commit bc3a74bbcb
10 changed files with 25 additions and 206 deletions

36
package-lock.json generated
View file

@ -2150,14 +2150,12 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -2172,20 +2170,17 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -2302,8 +2297,7 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -2315,7 +2309,6 @@
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -2330,7 +2323,6 @@
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -2338,14 +2330,12 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz",
"integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -2364,7 +2354,6 @@
"version": "0.5.1", "version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -2445,8 +2434,7 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -2458,7 +2446,6 @@
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -2580,7 +2567,6 @@
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -11271,14 +11257,6 @@
"errno": "~0.1.7" "errno": "~0.1.7"
} }
}, },
"workerize-loader": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/workerize-loader/-/workerize-loader-1.0.4.tgz",
"integrity": "sha512-HMTr/zpuZhm8dbhcK52cMYmn57uf7IJeMZJil+5lL/vC5+AO9wzxZ0FISkGVj78No7HcpaINwAWHGCYx3dnsTw==",
"requires": {
"loader-utils": "^1.1.0"
}
},
"wrap-ansi": { "wrap-ansi": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",

View file

@ -98,8 +98,7 @@
"tiny-queue": "^0.2.1", "tiny-queue": "^0.2.1",
"web-animations-js": "^2.3.1", "web-animations-js": "^2.3.1",
"webpack": "^4.20.2", "webpack": "^4.20.2",
"webpack-bundle-analyzer": "^3.0.2", "webpack-bundle-analyzer": "^3.0.2"
"workerize-loader": "^1.0.4"
}, },
"devDependencies": { "devDependencies": {
"eslint-plugin-html": "^4.0.6", "eslint-plugin-html": "^4.0.6",

View file

@ -56,7 +56,7 @@ export async function logOutOfInstance (instanceName) {
store.save() store.save()
toast.say(`Logged out of ${instanceName}`) toast.say(`Logged out of ${instanceName}`)
switchToTheme(instanceThemes[newInstance] || 'default') switchToTheme(instanceThemes[newInstance] || 'default')
await database.clearDatabaseForInstance(instanceName) /* no await */ database.clearDatabaseForInstance(instanceName)
goto('/settings/instances') goto('/settings/instances')
} }

View file

@ -40,7 +40,7 @@
showConfirmationDialog({ showConfirmationDialog({
text: `Log out of ${instanceName}?`, text: `Log out of ${instanceName}?`,
onPositive () { onPositive () {
logOutOfInstance(instanceName) /* no await */ logOutOfInstance(instanceName)
} }
}) })
} }

View file

@ -1,3 +1,3 @@
// dev version to play nice with IDEs // this used to be workerized, hence the API looks like this
import * as database from './databaseWorker' import * as database from './databaseApis'
export { database } export { database }

View file

@ -1,3 +0,0 @@
// workerize version, used in production
const database = process.browser && require('./databaseWorker.js')()
export { database }

View file

@ -0,0 +1,11 @@
export * from './accounts'
export * from './clear'
export * from './timelines/lookup'
export * from './timelines/pinnedStatuses'
export * from './timelines/pagination'
export * from './timelines/getStatusOrNotification'
export * from './timelines/updateStatus'
export * from './timelines/deletion'
export * from './timelines/insertion'
export * from './meta'
export * from './relationships'

View file

@ -126,5 +126,6 @@ export function deleteDatabase (instanceName) {
let req = indexedDB.deleteDatabase(instanceName) let req = indexedDB.deleteDatabase(instanceName)
req.onsuccess = () => resolve() req.onsuccess = () => resolve()
req.onerror = () => reject(req.error) req.onerror = () => reject(req.error)
req.onblocked = () => console.error(`database ${instanceName} blocked`)
}).then(() => deleteKnownInstance(instanceName)) }).then(() => deleteKnownInstance(instanceName))
} }

View file

@ -1,157 +0,0 @@
import {
getAccount as _getAccount,
searchAccountsByUsername as _searchAccountsByUsername,
setAccount as _setAccount
} from './accounts'
import {
clearDatabaseForInstance as _clearDatabaseForInstance
} from './clear'
import {
getNotificationIdsForStatuses as _getNotificationIdsForStatuses,
getReblogsForStatus as _getReblogsForStatus
} from './timelines/lookup'
import {
getPinnedStatuses as _getPinnedStatuses,
insertPinnedStatuses as _insertPinnedStatuses
} from './timelines/pinnedStatuses'
import {
getTimeline as _getTimeline
} from './timelines/pagination'
import {
getNotification as _getNotification,
getStatus as _getStatus
} from './timelines/getStatusOrNotification'
import {
setStatusFavorited as _setStatusFavorited,
setStatusMuted as _setStatusMuted,
setStatusPinned as _setStatusPinned,
setStatusReblogged as _setStatusReblogged
} from './timelines/updateStatus'
import {
deleteStatusesAndNotifications as _deleteStatusesAndNotifications
} from './timelines/deletion'
import {
insertTimelineItems as _insertTimelineItems
} from './timelines/insertion'
import {
getCustomEmoji as _getCustomEmoji,
getInstanceInfo as _getInstanceInfo,
getInstanceVerifyCredentials as _getInstanceVerifyCredentials,
getLists as _getLists,
setCustomEmoji as _setCustomEmoji,
setInstanceInfo as _setInstanceInfo,
setInstanceVerifyCredentials as _setInstanceVerifyCredentials,
setLists as _setLists
} from './meta'
import {
getRelationship as _getRelationship,
setRelationship as _setRelationship
} from './relationships'
export async function getAccount (instanceName, accountId) {
return _getAccount(instanceName, accountId)
}
export async function setAccount (instanceName, account) {
return _setAccount(instanceName, account)
}
export async function searchAccountsByUsername (instanceName, usernamePrefix, limit) {
return _searchAccountsByUsername(instanceName, usernamePrefix, limit)
}
export async function clearDatabaseForInstance (instanceName) {
return _clearDatabaseForInstance(instanceName)
}
export async function getReblogsForStatus (instanceName, id) {
return _getReblogsForStatus(instanceName, id)
}
export async function getNotificationIdsForStatuses (instanceName, statusIds) {
return _getNotificationIdsForStatuses(instanceName, statusIds)
}
export async function insertPinnedStatuses (instanceName, accountId, statuses) {
return _insertPinnedStatuses(instanceName, accountId, statuses)
}
export async function getPinnedStatuses (instanceName, accountId) {
return _getPinnedStatuses(instanceName, accountId)
}
export async function getTimeline (instanceName, timeline, maxId, limit) {
return _getTimeline(instanceName, timeline, maxId, limit)
}
export async function getStatus (instanceName, id) {
return _getStatus(instanceName, id)
}
export async function getNotification (instanceName, id) {
return _getNotification(instanceName, id)
}
export async function setStatusFavorited (instanceName, statusId, favorited) {
return _setStatusFavorited(instanceName, statusId, favorited)
}
export async function setStatusReblogged (instanceName, statusId, reblogged) {
return _setStatusReblogged(instanceName, statusId, reblogged)
}
export async function setStatusPinned (instanceName, statusId, pinned) {
return _setStatusPinned(instanceName, statusId, pinned)
}
export async function setStatusMuted (instanceName, statusId, muted) {
return _setStatusMuted(instanceName, statusId, muted)
}
export async function deleteStatusesAndNotifications (instanceName, statusIds, notificationIds) {
return _deleteStatusesAndNotifications(instanceName, statusIds, notificationIds)
}
export async function insertTimelineItems (instanceName, timeline, timelineItems) {
return _insertTimelineItems(instanceName, timeline, timelineItems)
}
export async function getInstanceVerifyCredentials (instanceName) {
return _getInstanceVerifyCredentials(instanceName)
}
export async function setInstanceVerifyCredentials (instanceName, value) {
return _setInstanceVerifyCredentials(instanceName, value)
}
export async function getInstanceInfo (instanceName) {
return _getInstanceInfo(instanceName)
}
export async function setInstanceInfo (instanceName, value) {
return _setInstanceInfo(instanceName, value)
}
export async function getLists (instanceName) {
return _getLists(instanceName)
}
export async function setLists (instanceName, value) {
return _setLists(instanceName, value)
}
export async function getCustomEmoji (instanceName) {
return _getCustomEmoji(instanceName)
}
export async function setCustomEmoji (instanceName, value) {
return _setCustomEmoji(instanceName, value)
}
export async function getRelationship (instanceName, accountId) {
return _getRelationship(instanceName, accountId)
}
export async function setRelationship (instanceName, relationship) {
return _setRelationship(instanceName, relationship)
}

View file

@ -45,12 +45,6 @@ module.exports = {
MiniCssExtractPlugin.loader, MiniCssExtractPlugin.loader,
'css-loader' 'css-loader'
] ]
},
{
test: /\/_database\/databaseWorker\.js$/,
use: [
'workerize-loader'
]
} }
].filter(Boolean) ].filter(Boolean)
}, },
@ -85,11 +79,7 @@ module.exports = {
plugins: [ plugins: [
new LodashModuleReplacementPlugin({ new LodashModuleReplacementPlugin({
paths: true paths: true
}), })
new webpack.NormalModuleReplacementPlugin(
/\/_database\/database\.js$/,
'./database.workerize.js'
)
].concat(isDev ? [ ].concat(isDev ? [
new webpack.HotModuleReplacementPlugin({ new webpack.HotModuleReplacementPlugin({
requestTimeout: 120000 requestTimeout: 120000