Skip to content

Commit

Permalink
Fix ~2min hang seen when making requests since changing to Node 20
Browse files Browse the repository at this point in the history
The default for keepAlive on https request changed from false to true in Node 19
nodejs/node#47228
  • Loading branch information
Jamie- committed Feb 13, 2024
1 parent 6f91a97 commit a642161
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ function constructPayload(inputs, callback) {

// Send a Slack notification
function notifySlack(payload) {
console.log("Sending message to Slack...");
const url = new URL(process.env.SLACK_WEBHOOK_URL);

const options = {
hostname: url.hostname,
port: 443,
Expand All @@ -141,16 +141,15 @@ function notifySlack(payload) {
"Content-Type": "application/json",
"Content-Length": payload.length,
},
agent: new https.Agent({ keepAlive: false }),
};

const req = https.request(options, res => {
if (res.statusCode === 200) {
console.log("Sent message to Slack OK");
} else {
console.log("Failed to post to Slack!", res);
}
});

req.write(payload);
req.end();
}
Expand Down

0 comments on commit a642161

Please sign in to comment.