Skip to content

Commit f239427

Browse files
committed
fix: ensure functions return promises in createSingleton and createLock
1 parent f350920 commit f239427

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/common/promise.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const createSingleton = <T>(fn: AsyncFn<T>): Singleton<T> => {
3434

3535
const wrapper: Singleton<T> = () => {
3636
if (!p) {
37-
p = fn();
37+
p = Promise.resolve(fn());
3838
}
3939

4040
return p;
@@ -70,7 +70,7 @@ export const createLock = (): Lock => {
7070

7171
return {
7272
async run(fn) {
73-
const p = fn();
73+
const p = Promise.resolve(fn());
7474
locks.push(p);
7575

7676
try {

0 commit comments

Comments
 (0)