Skip to content

Commit

Permalink
wait for updateAssembly when restoring
Browse files Browse the repository at this point in the history
fixes potential race condition
  • Loading branch information
mifi committed Aug 9, 2024
1 parent b21058e commit a457a64
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/@uppy/transloadit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,20 +703,21 @@ export default class Transloadit<
this.#connectAssembly(this.assembly)
}

// Force-update all Assemblies to check for missed events.
const updateAssemblies = () => {
// Force-update Assembly to check for missed events.
const updateAssembly = () => {
return this.assembly?.update()
}

// Restore all Assembly state.
this.restored = Promise.resolve().then(() => {
this.restored = (async () => {
restoreState()
restoreAssemblies()
updateAssemblies()
})

this.restored.then(() => {
await updateAssembly()
this.restored = null
})()

this.restored.catch((err) => {
this.uppy.log('Failed to restore', err) // or we risk unhandled rejection
})
}

Expand Down

0 comments on commit a457a64

Please sign in to comment.