Skip to content

Commit

Permalink
fix(server): clearTimeout before resolver or reject
Browse files Browse the repository at this point in the history
  • Loading branch information
HsuTing authored and nodkz committed Jun 19, 2019
1 parent 0c11165 commit 7cfb022
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -61,8 +61,11 @@ export default class RelayServerSSR {
} else {
payload = await next(r);
}

clearTimeout(timeout);
resolve(payload);
} catch (e) {
clearTimeout(timeout);
reject(e);
}
});
Expand Down

0 comments on commit 7cfb022

Please sign in to comment.