fix: run idb cleanups in requestIdleCallback (#1470)
This commit is contained in:
parent
26a036259e
commit
d71d6b49ef
|
@ -17,6 +17,7 @@ import { createPinnedStatusKeyRange, createThreadKeyRange } from './keys'
|
||||||
import { getKnownInstances } from './knownInstances'
|
import { getKnownInstances } from './knownInstances'
|
||||||
import noop from 'lodash-es/noop'
|
import noop from 'lodash-es/noop'
|
||||||
import { CLEANUP_DELAY, CLEANUP_TIME_AGO } from '../_static/database'
|
import { CLEANUP_DELAY, CLEANUP_TIME_AGO } from '../_static/database'
|
||||||
|
import { scheduleIdleTask } from '../_utils/scheduleIdleTask'
|
||||||
|
|
||||||
const BATCH_SIZE = 20
|
const BATCH_SIZE = 20
|
||||||
|
|
||||||
|
@ -134,8 +135,7 @@ export async function cleanup (instanceName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function doCleanup (instanceName) {
|
function doCleanup (instanceName) {
|
||||||
// run in setTimeout because we're in a worker and there's no requestIdleCallback
|
scheduleIdleTask(() => cleanup(instanceName))
|
||||||
setTimeout(() => cleanup(instanceName))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function scheduledCleanup () {
|
async function scheduledCleanup () {
|
||||||
|
|
Loading…
Reference in a new issue