From 717f86332fc31119046bed0ec53516a3d392337a Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 31 Oct 2022 12:39:23 +0000 Subject: [PATCH 1/4] Disable keepalive to prevent hanging connections --- bindings/matrix-sdk-crypto-nodejs/download-lib.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bindings/matrix-sdk-crypto-nodejs/download-lib.js b/bindings/matrix-sdk-crypto-nodejs/download-lib.js index ec7c157e3..58f73a479 100644 --- a/bindings/matrix-sdk-crypto-nodejs/download-lib.js +++ b/bindings/matrix-sdk-crypto-nodejs/download-lib.js @@ -1,3 +1,6 @@ + +const { Agent } = require('https'); +const { whyIsNodeStillRunning } = require('why-is-node-still-running'); const { DownloaderHelper } = require('node-downloader-helper'); const { version } = require("./package.json"); const { platform, arch } = process @@ -22,10 +25,17 @@ function download_lib(libname) { console.info(`Downloading lib ${libname} from ${url}`); const dl = new DownloaderHelper(url, __dirname, { override: true, + httpsRequestOptions: { + // Disable keepalive to prevent the process hanging open. + // https://github.com/matrix-org/matrix-rust-sdk/issues/1160 + agent: new Agent({ keepAlive: false }), + }, }); dl.on('end', () => console.info('Download Completed')); dl.on('error', (err) => console.info('Download Failed', err)); + dl.on('stateChanged', (err) => console.info('Download state', err)); + dl.on('timeout', (err) => console.info('Download timeout', err)); dl.on('progress', stats => { const progress = stats.progress.toFixed(1); const speed = byteHelper(stats.speed); @@ -35,7 +45,7 @@ function download_lib(libname) { // print every one second (`progress.throttled` can be used instead) const currentTime = new Date(); const elaspsedTime = currentTime - startTime; - if (elaspsedTime > 1000) { + if (elaspsedTime > 1000 || stats.progress === 100) { startTime = currentTime; console.info(`${speed}/s - ${progress}% [${downloaded}/${total}]`); } @@ -110,4 +120,4 @@ switch (platform) { break default: throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`) -} +} \ No newline at end of file From 546dc9a6523026328e1f7386aca5c8bbc9334ea5 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 31 Oct 2022 13:04:05 +0000 Subject: [PATCH 2/4] Run CI against 19 --- .github/workflows/bindings_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bindings_ci.yml b/.github/workflows/bindings_ci.yml index 235e62d77..128eeebac 100644 --- a/.github/workflows/bindings_ci.yml +++ b/.github/workflows/bindings_ci.yml @@ -92,7 +92,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - node-version: [14.0, 16.0, 18.0] + node-version: [14.0, 16.0, 18.0, 19.0] include: - os: ubuntu-latest os-name: 🐧 From c009f54ba9f4b4cc99f3e64287ba97a67321f6b5 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 31 Oct 2022 13:17:48 +0000 Subject: [PATCH 3/4] Tidy --- bindings/matrix-sdk-crypto-nodejs/download-lib.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bindings/matrix-sdk-crypto-nodejs/download-lib.js b/bindings/matrix-sdk-crypto-nodejs/download-lib.js index 58f73a479..e6ea74935 100644 --- a/bindings/matrix-sdk-crypto-nodejs/download-lib.js +++ b/bindings/matrix-sdk-crypto-nodejs/download-lib.js @@ -1,6 +1,5 @@ const { Agent } = require('https'); -const { whyIsNodeStillRunning } = require('why-is-node-still-running'); const { DownloaderHelper } = require('node-downloader-helper'); const { version } = require("./package.json"); const { platform, arch } = process @@ -34,8 +33,6 @@ function download_lib(libname) { dl.on('end', () => console.info('Download Completed')); dl.on('error', (err) => console.info('Download Failed', err)); - dl.on('stateChanged', (err) => console.info('Download state', err)); - dl.on('timeout', (err) => console.info('Download timeout', err)); dl.on('progress', stats => { const progress = stats.progress.toFixed(1); const speed = byteHelper(stats.speed); @@ -45,7 +42,7 @@ function download_lib(libname) { // print every one second (`progress.throttled` can be used instead) const currentTime = new Date(); const elaspsedTime = currentTime - startTime; - if (elaspsedTime > 1000 || stats.progress === 100) { + if (elaspsedTime > 1000) { startTime = currentTime; console.info(`${speed}/s - ${progress}% [${downloaded}/${total}]`); } @@ -120,4 +117,4 @@ switch (platform) { break default: throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`) -} \ No newline at end of file +} From f4f3ca4b25d2b0d6e86a3a120a7e90c9f7766eaf Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 31 Oct 2022 13:18:16 +0000 Subject: [PATCH 4/4] A newline --- bindings/matrix-sdk-crypto-nodejs/download-lib.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bindings/matrix-sdk-crypto-nodejs/download-lib.js b/bindings/matrix-sdk-crypto-nodejs/download-lib.js index e6ea74935..d0aec7d78 100644 --- a/bindings/matrix-sdk-crypto-nodejs/download-lib.js +++ b/bindings/matrix-sdk-crypto-nodejs/download-lib.js @@ -1,4 +1,3 @@ - const { Agent } = require('https'); const { DownloaderHelper } = require('node-downloader-helper'); const { version } = require("./package.json");