Skip to content

Commit

Permalink
Merge pull request #121 from alexanderson1993/master
Browse files Browse the repository at this point in the history
Clears the invocation timeout if the invocation is a success.
  • Loading branch information
swyxio authored Feb 13, 2019
2 parents 6f470ae + 20cb467 commit 879211d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,20 @@ function createHandler(dir, static, timeout) {
{ clientContext: buildClientContext(request.headers) || {} },
callback
);

var invocationTimeoutRef = null

Promise.race([
promiseCallback(promise, callback),
setTimeout(function() {
handleInvocationTimeout(response, timeout)
}, timeout * 1000)
])
new Promise(function(resolve) {
invocationTimeoutRef = setTimeout(function() {
handleInvocationTimeout(response, timeout)
resolve()
}, timeout * 1000)
})
]).finally(() => {
clearTimeout(invocationTimeoutRef)
})
};
}

Expand Down

0 comments on commit 879211d

Please sign in to comment.