gajus / gajus/pg-formatter

postinstall script takes 30s on node19+ due to keepalive

Open
#36 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
83
Forks
17
PR merge metrics
No merged PRs in 30d

Description

From node 19 (e.g. Node 20, Node 22 LTS), they set keepAlive by default to true. This causes a behaviour (bug?) https://github.com/nodejs/node/issues/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
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`;
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in bin/postinstall-script.cjs and review the postinstall command shown in the issue, along with the Node.js keepalive behavior it references. Apply the requested keepalive change and run node node_modules/pg-formatter/bin/postinstall-script.js on Node 19 or newer, verifying that it exits promptly instead of taking about 30 seconds.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
build-system
Issue type
Bug
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.