diff --git a/src/api.server.ts b/src/api.server.ts index 19af1fe..8afddc0 100644 --- a/src/api.server.ts +++ b/src/api.server.ts @@ -139,7 +139,7 @@ export class ApiServer { private setFormatSend() { this.server.addHook('preSerialization', async (req: FastifyRequest, reply: FastifyReply, payload) => { reply.header('X-Powered-By', 'PHP/5.4.16') - new SyncLocker().unlock(req) + await new SyncLocker().unlock(req) // @ts-ignore if (!payload.errcode) { payload = { diff --git a/src/common/SyncLocker.ts b/src/common/SyncLocker.ts index ab8f972..0e46d26 100644 --- a/src/common/SyncLocker.ts +++ b/src/common/SyncLocker.ts @@ -24,7 +24,7 @@ const redlock = new Redlock( // The max number of times Redlock will attempt to lock a resource // before erroring. - retryCount: 10, + retryCount: 0, // the time in ms between attempts retryDelay: 200, // time in ms @@ -51,9 +51,9 @@ redlock.on('error', error => { @singleton export class SyncLocker { - public unlock(req: IRequest) { + public async unlock(req: IRequest) { if (req.lock) { - req.lock.release() + await req.lock.release() } }