Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postinstall script takes 30s on node19+ due to keepalive #36

Open
phiresky opened this issue Mar 5, 2025 · 1 comment · May be fixed by #37
Open

postinstall script takes 30s on node19+ due to keepalive #36

phiresky opened this issue Mar 5, 2025 · 1 comment · May be fixed by #37

Comments

@phiresky
Copy link

phiresky commented Mar 5, 2025

From node 19 (e.g. Node 20, Node 22 LTS), they set keepAlive by default to true. This causes a behaviour (bug?) nodejs/node#47228 where the process also does not exit for 30 seconds.

This can be fixed with this patch

before:
node node_modules/pg-formatter/bin/postinstall-script.js 0,50s user 0,25s system 2% cpu 30,255 total

after:

node node_modules/pg-formatter/bin/postinstall-script.js 0,60s user 0,27s system 61% cpu 1,391 total

patch: (too lazy to make a PR)

diff --git a/bin/postinstall-script.cjs b/bin/postinstall-script.cjs
index 1049542..19e7db8 100644
--- a/bin/postinstall-script.cjs
+++ b/bin/postinstall-script.cjs
@@ -5,6 +5,9 @@ const zlib = require('node:zlib');
 const rimraf = require('rimraf');
 const tar = require('tar-fs');
 
+// skript takes 30s otherwise
+// https://github.com/nodejs/node/issues/47228 where the process also does not exit for 30 seconds.
+https.globalAgent.keepAlive = false;
 const destination = path.resolve(__dirname, '../src/pg-formatter');
 const secondaryDestination = path.resolve(__dirname, '../dist/pg-formatter');
 const libraryUrl = `https://github.com/darold/pgFormatter/archive/refs/tags/v5.5.tar.gz`;
@phiresky
Copy link
Author

phiresky commented Mar 5, 2025

This also makes any npm install or yarn install of a package depending on this 30s slower and thus makes our CI 30s slower ;)

@phiresky phiresky linked a pull request Mar 5, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant