Skip to content

Commit

Permalink
reset listening state for each secondary server (#4810)
Browse files Browse the repository at this point in the history
The listenCallback() function is called for each secondary
address that a server should listen on. However, each call sets
the listening state to true, so subsequent addresses fail with
FST_ERR_REOPENED_SERVER. This commit resets the state on each
call.
  • Loading branch information
cjihrig committed Jun 9, 2023
1 parent 48ae3a7 commit 96068f9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function multipleBindings (mainServer, httpHandler, serverOpts, listenOptions, o
cb: (_ignoreErr) => {
binded++

/* istanbul ignore next: the else won't be taken unless listening fails */
if (!_ignoreErr) {
this[kServerBindings].push(secondaryServer)
}
Expand All @@ -144,6 +145,7 @@ function multipleBindings (mainServer, httpHandler, serverOpts, listenOptions, o
mainServer.on('unref', closeSecondary)
mainServer.on('close', closeSecondary)
mainServer.on('error', closeSecondary)
this[kState].listening = false
listenCallback.call(this, secondaryServer, secondaryOpts)()
}
}
Expand Down

0 comments on commit 96068f9

Please sign in to comment.