Skip to content

Commit c1ac739

Browse files
committed
More fixes.
1 parent c28f65d commit c1ac739

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

packages/workflow/src/internals.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -528,17 +528,8 @@ export class Activator implements ActivationHandler {
528528
}
529529

530530
public bindCurrentRandom<T extends (...args: any[]) => any>(fn: T): T {
531-
const storage = (this.currentRandomStorage ??= new AsyncLocalStorage<ScopedWorkflowRandomSource | undefined>());
532-
const randomSource = storage.getStore();
533-
const bind = (
534-
AsyncLocalStorage as typeof AsyncLocalStorage & {
535-
bind?: <F extends (...args: any[]) => any>(fn: F) => F;
536-
}
537-
).bind;
538-
if (bind) {
539-
return storage.run(randomSource, () => bind(fn)) as T;
540-
}
541-
return ((...args: Parameters<T>) => storage.run(randomSource, () => fn(...args))) as unknown as T;
531+
const randomSource = this.currentRandomStorage?.getStore();
532+
return ((...args: Parameters<T>) => this.withRandomSource(randomSource, () => fn(...args))) as unknown as T;
542533
}
543534

544535
public currentRandom(): number {

0 commit comments

Comments
 (0)