Skip to content

Commit

Permalink
fix (builder-util-runtime): set timeout when request is closed (elect…
Browse files Browse the repository at this point in the history
  • Loading branch information
clusterberries authored Feb 23, 2020
1 parent f5cc292 commit caebf37
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/builder-util-runtime/src/httpExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,16 @@ Please double check that your authentication token is correct. Due to security r
}

private addTimeOutHandler(request: any, callback: (error: Error) => void) {
const timeoutCb = () => {
request.abort()
callback(new Error("Request timed out"))
}

request.on("socket", (socket: Socket) => {
socket.setTimeout(60 * 1000, () => {
request.abort()
callback(new Error("Request timed out"))
})
socket.setTimeout(60 * 1000, timeoutCb)
})
request.on("close", () => {
setTimeout(timeoutCb, 30 * 1000)
})
}

Expand Down

0 comments on commit caebf37

Please sign in to comment.