Skip to content

Commit 05e4001

Browse files
committed
fix idle timeout issue
details of bug are here: nodejs/node#13391 docs here: https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_server_keepalivetimeout tl;dr is node set a 5s idle timeout. this does what go and java both seem to do (have not checked python or ruby, though from what I know about python, we are not doing this either) and doesn't have an idle timeout. since in this case we do kinda trust that the client is using an idle timeout (it's fn), this seems like the right policy anyway (if fn dies is something to consider, but the least of our worries is fdk conns in that case, and we are killing fn spawned containers on startup too). it should also be noted the client (fn) is only using 1 conn per container.
1 parent a028b75 commit 05e4001

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

fn-fdk.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,15 @@ function handleHTTPStream (fnfunction, options) {
288288
}
289289

290290
let currentServer = http.createServer(functionHandler)
291-
.listen(tmpFile, () => {
292-
fs.chmodSync(tmpFile, '666')
293-
fs.symlinkSync(tmpFileBaseName, listenFile)
294-
})
295-
.on('error', (error) => {
296-
console.warn(`Unable to connect to unix socket ${tmpFile}`, error)
297-
process.exit(3)
298-
})
291+
currentServer.keepAliveTimeout = 0 // turn off
292+
currentServer.listen(tmpFile, () => {
293+
fs.chmodSync(tmpFile, '666')
294+
fs.symlinkSync(tmpFileBaseName, listenFile)
295+
})
296+
currentServer.on('error', (error) => {
297+
console.warn(`Unable to connect to unix socket ${tmpFile}`, error)
298+
process.exit(3)
299+
})
299300

300301
return () => {
301302
currentServer.close()

0 commit comments

Comments
 (0)