Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(deps): patch npm's bundled HTTP client
Yudhi Armyndharis93888ed25770
diff --git a/.github/workflows/js-sdk-release.yml b/.github/workflows/js-sdk-release.ymlindex 448e549e9..e692f5a66 100644--- a/.github/workflows/js-sdk-release.yml+++ b/.github/workflows/js-sdk-release.yml@@ -126,6 +126,13 @@ jobs:# not float to whatever version is current when the tag is pushed.run: |npm install -g [email protected]+ npm_bundle_dir="$(npm root --global)/npm/node_modules"+ node -e "if (require(process.argv[1]).version !== '6.29.0') throw new Error('Recheck npm Undici replacement');" "$npm_bundle_dir/undici/package.json"+ npm_http_patch_dir=$(mktemp -d)+ npm install --prefix "$npm_http_patch_dir" --no-save --package-lock=false --ignore-scripts --no-audit --fund=false [email protected]+ rm -rf "$npm_bundle_dir/undici"+ mv "$npm_http_patch_dir/node_modules/undici" "$npm_bundle_dir/undici"+ rm -rf "$npm_http_patch_dir"npm --version- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f2974ca5e..22bd75471 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed- Update multer to 2.5.0 and undici to 8.12.3 to prevent request teardown and response decoding failures.+- Patch npm's bundled Undici to 6.29.1 in the production image and JavaScript SDK publishing toolchain.- Keep deleted sessions free of late message, status and bulk writes, and of the `message:failed` event of a bulk item whose session was deleted before it was sent.- Retain sending limits while hooks or preparation are pending, including across UTC midnight.- Preserve whatsapp-web.js readiness when an earlier QR render completes.diff --git a/Dockerfile b/Dockerfileindex 8c571adf2..d42a6b1a6 100644--- a/Dockerfile+++ b/Dockerfile@@ -234,7 +234,16 @@ RUN npm ci --omit=dev --ignore-scripts \# Deliberately AFTER `npm ci`, so the application tree is still resolved by the npm the lockfile# was generated with and only the global CLI is swapped. Pinned to the exact patch release —# a floating npm@12 would make the image's bundled npm tree depend on when the build happened.-RUN npm install -g [email protected] && npm cache clean --force+# npm 12.2.1 still bundles Undici 6.29.0. Replace only that package with its compatible patch;+# npm's bundled private packages prevent reinstalling its dependency tree from the registry.+RUN npm install -g [email protected] && \+ node -e "if (require('/usr/local/lib/node_modules/npm/node_modules/undici/package.json').version !== '6.29.0') throw new Error('Recheck npm Undici replacement');" && \+ npm_http_patch_dir=$(mktemp -d) && \+ npm install --prefix "$npm_http_patch_dir" --no-save --package-lock=false --ignore-scripts --no-audit --fund=false [email protected] && \+ rm -rf /usr/local/lib/node_modules/npm/node_modules/undici && \+ mv "$npm_http_patch_dir/node_modules/undici" /usr/local/lib/node_modules/npm/node_modules/undici && \+ rm -rf "$npm_http_patch_dir" && \+ npm cache clean --force# amd64: download Chrome for Testing via Puppeteer and symlink it.# arm64: use Debian's chromium installed above (a choice; see the note at that install).diff --git a/src/common/ci-privilege-gate.spec.ts b/src/common/ci-privilege-gate.spec.tsindex 926847e04..205803aba 100644--- a/src/common/ci-privilege-gate.spec.ts+++ b/src/common/ci-privilege-gate.spec.ts@@ -553,7 +553,17 @@ describe('a job that can mint a publish credential pins global npm installs and{ uses: 'actions/setup-node', with: { 'node-version': /^\d+$/ } },{name: 'Use an npm that supports trusted publishing',- run: [/^npm install -g npm@\d+\.\d+\.\d+$/, 'npm --version'],+ run: [+ /^npm install -g npm@\d+\.\d+\.\d+$/,+ 'npm_bundle_dir="$(npm root --global)/npm/node_modules"',+ `node -e "if (require(process.argv[1]).version !== '6.29.0') throw new Error('Recheck npm Undici replacement');" "$npm_bundle_dir/undici/package.json"`,+ 'npm_http_patch_dir=$(mktemp -d)',+ 'npm install --prefix "$npm_http_patch_dir" --no-save --package-lock=false --ignore-scripts --no-audit --fund=false [email protected]',+ 'rm -rf "$npm_bundle_dir/undici"',+ 'mv "$npm_http_patch_dir/node_modules/undici" "$npm_bundle_dir/undici"',+ 'rm -rf "$npm_http_patch_dir"',+ 'npm --version',+ ],},{ uses: 'actions/download-artifact', with: { name: 'js-sdk-package', path: 'package/' } },{@@ -1447,6 +1457,21 @@ describe('a job that can mint a publish credential pins global npm installs andconst lastNpm = show(npmRun[npmRun.length - 1]);const publishLine = show(scriptOf(JS_PUBLISH, publish)[0]);expectOutsideTemplate('js-sdk-release.yml', [+ ...(+ [+ ['a floating HTTP client pin', 4, '[email protected]', 'undici@latest'],+ ['HTTP client install scripts enabled', 4, ' --ignore-scripts', ''],+ ['removal outside the HTTP client package', 5, '"$npm_bundle_dir/undici"', '"$npm_bundle_dir"'],+ ] as const+ ).map(([label, index, from, to]): TemplateCase => {+ const original = show(npmRun[index]);+ const changed = original.replace(from, to);+ return [+ label,+ w => swap(steps(w)[npm], original, changed),+ [`publish step ${npm + 1} "${NPM}": run line ${index + 1}: ${changed}, expected ${original}`],+ ];+ }),['the publish ahead of the npm it needs',exchange('publish', npm, publish),