feat(task): put async storage in the global scope

This commit is contained in:
Julien Fontanet
2023-04-17 16:01:55 +02:00
parent e9b658b60d
commit 12552a1391
2 changed files with 5 additions and 2 deletions

View File

@@ -17,7 +17,10 @@ const PENDING = 'pending'
const SUCCESS = 'success'
exports.STATUS = { ABORTED, ABORTING, FAILURE, PENDING, SUCCESS }
const asyncStorage = new AsyncLocalStorage()
// stored in the global context so that various versions of the library can interact.
const asyncStorageKey = '@vates/task@0'
const asyncStorage = global[asyncStorageKey] ?? (global[asyncStorageKey] = new AsyncLocalStorage())
const getTask = () => asyncStorage.getStore()
exports.Task = class Task {

View File

@@ -39,7 +39,7 @@
- @vates/diff minor
- @vates/read-chunk patch
- @vates/stream-reader minor
- @vates/task patch
- @vates/task minor
- @xen-orchestra/backups minor
- @xen-orchestra/mixins minor
- vhd-lib minor