fix(kopiaui): Add timeout in pollOnce https.request equal to poll interval (#3055)

Co-authored-by: Jarek Kowalski <jaak@jkowalski.net>
This commit is contained in:
Till Riedel
2024-02-21 05:23:28 +00:00
committed by GitHub
parent ca2230f9c6
commit c6536dfdaf

View File

@@ -67,6 +67,8 @@ function newServerForRepo(repoID) {
const statusUpdated = this.raiseStatusUpdatedEvent.bind(this);
const pollInterval = 3000;
function pollOnce() {
if (!runningServerAddress || !runningServerCertificate || !runningServerPassword || !runningServerControlPassword) {
return;
@@ -78,6 +80,7 @@ function newServerForRepo(repoID) {
port: parseInt(new URL(runningServerAddress).port),
method: "GET",
path: "/api/v1/control/status",
timeout: pollInterval,
headers: {
'Authorization': 'Basic ' + Buffer.from("server-control" + ':' + runningServerControlPassword).toString('base64')
}
@@ -104,7 +107,7 @@ function newServerForRepo(repoID) {
req.end();
}
const statusPollInterval = setInterval(pollOnce, 3000);
const statusPollInterval = setInterval(pollOnce, pollInterval);
runningServerProcess.on('close', (code, signal) => {
this.appendToLog(`child process exited with code ${code} and signal ${signal}`);