From 7cfb0221d277c87a3774ecfa97b4720fa90fe9e2 Mon Sep 17 00:00:00 2001 From: Ting-Hsiang Hsu Date: Wed, 19 Jun 2019 23:59:48 +0800 Subject: [PATCH] fix(server): clearTimeout before resolver or reject --- src/server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/server.js b/src/server.js index abcbb40..0b29d13 100644 --- a/src/server.js +++ b/src/server.js @@ -46,7 +46,7 @@ export default class RelayServerSSR { const graphqlArgs: SSRGraphQLArgs = isFunction(args) ? await args() : (args: any); const hasSchema = graphqlArgs && graphqlArgs.schema; const gqlResponse = new Promise(async (resolve, reject) => { - setTimeout(() => { + const timeout = setTimeout(() => { reject(new Error('RelayRequest timeout')); }, 30000); @@ -61,8 +61,11 @@ export default class RelayServerSSR { } else { payload = await next(r); } + + clearTimeout(timeout); resolve(payload); } catch (e) { + clearTimeout(timeout); reject(e); } });