Skip to content

fix: silence DEP0169 url.parse deprecation from bundled aws-sdk v2#6

Merged
kurok merged 1 commit intofeat/al2023-supportfrom
fix/aws-sdk-url-parse-deprecation
Apr 20, 2026
Merged

fix: silence DEP0169 url.parse deprecation from bundled aws-sdk v2#6
kurok merged 1 commit intofeat/al2023-supportfrom
fix/aws-sdk-url-parse-deprecation

Conversation

@kurok
Copy link
Copy Markdown

@kurok kurok commented Apr 20, 2026

Summary

Filter only DEP0169 (url.parse() deprecation) at process.emitWarning. 15-line change in src/index.js, equivalent 15-line diff in rebuilt dist/index.js. No dependency updates.

What surfaces the warning

The bundled aws-sdk v2 (^2.809.0 → resolves to 2.814.0) calls url.parse() in three places in its distributed bundle. Only AWS.util.urlParse runs at runtime — it's called on every EC2 API invocation to parse service endpoints. Node 24 emits the deprecation on each call:

(node:2120) [DEP0169] DeprecationWarning: `url.parse()` behavior is not
standardized and prone to errors that have security implications.
Use the WHATWG URL API instead. CVEs are not issued for `url.parse()`
vulnerabilities.

Screenshot trail: the warning appeared on the very run that verified #4 / #5 landed and silenced the earlier ::set-output and node20 deprecations. One warning dies, the next surfaces.

Why not bump aws-sdk or migrate to v3

  • Bumping v2 to latest (2.1693.0) was tested — same three url.parse() sites still present. SDK v2 is in maintenance mode (end-of-support Nov 2025 per AWS), so this warning will not be fixed upstream.
  • aws-sdk v3 does use WHATWG URL, but v3 is a ground-up rewrite with per-service packages and a different API (@aws-sdk/client-ec2 + new EC2Client({...}) + send(new RunInstancesCommand({...}))). Migrating src/aws.js is a project unto itself, far beyond the scope of silencing a benign deprecation for fully-trusted EC2 endpoint URLs we construct ourselves.

Why the process.emitWarning override

A process.on('warning', ...) listener would be additive — Node's default stderr formatter is not a removable listener but a built-in path triggered from process.emit('warning', ...) regardless. To actually suppress the emission, we have to intercept at the source.

The override:

  • Extracts code from both supported call shapes: positional (msg, type, code, ctor) and options-object (msg, { code, type }).
  • Returns early only on 'DEP0169'.
  • Delegates everything else to the original process.emitWarning, which means user listeners, Node's default formatter, --trace-deprecation, --throw-deprecation, and any other machinery all continue to work for every other warning code.

Verification

Local smoke test (three call shapes):

node /tmp/warning-smoke.js
-> DEP0169 (filtered, silent)
-> DEP0123 options form (passed through with Node's default format)
-> Plain 2-arg Warning (passed through)

verify-dist CI job (added in #3) confirms the rebuild is reproducible: NODE_OPTIONS=--openssl-legacy-provider npm run package produces exactly the committed dist/index.js.

Consumer follow-up

Per the pattern established in #4 and #5, namecheap/terraform-provider-namecheap will rotate its SHA pin to the new feat/al2023-support tip after this merges. Two-line diff in its ci.yml.

The bundled aws-sdk v2 (^2.809.0 resolved to 2.814.0) uses url.parse()
internally for endpoint URL parsing. On node24 that triggers DEP0169
on every action invocation, surfacing as a warning on every consumer's
CI page:

  (node:PID) [DEP0169] DeprecationWarning: `url.parse()` behavior
  is not standardized and prone to errors that have security
  implications. Use the WHATWG URL API instead.

Three call sites verified in the bundled dist/: AWS.CloudFront's
getRtmpUrl, AWS.CloudFront.Signer.getSignedUrl, and AWS.util.urlParse.
Only the last runs at runtime (every EC2 API call parses its
endpoint). Upgrading aws-sdk to latest v2.1693 does not fix this —
the v2 SDK is in maintenance mode.

Migrating to aws-sdk v3 would rewrite src/aws.js entirely, far
beyond the scope of silencing a benign deprecation for trusted
EC2 endpoint URLs we control.

Instead, wrap process.emitWarning once at the top of src/index.js
and drop only the DEP0169 code. Every other warning — including
future new deprecations, user-installed 'warning' listeners, and
Node's default stderr formatter — is preserved by delegating to
the original emitWarning. Handles both call shapes:

  process.emitWarning(msg, type, code, ctor)    // positional
  process.emitWarning(msg, { code, type })      // options object

Smoke-tested locally with three call patterns:
- DEP0169 (filtered, silent)
- DEP0123 options form (passed through, Node's default format)
- Plain 2-arg Warning (passed through)

Signed-off-by: yuriyryabikov <22548029+kurok@users.noreply.github.com>
@kurok kurok merged commit 54459d6 into feat/al2023-support Apr 20, 2026
3 checks passed
kurok added a commit that referenced this pull request Apr 21, 2026
* feat: migrate aws-sdk v2 to @aws-sdk/client-ec2 v3 (Phase 1)

Completes Phase 1 (issue #7) of the modernization plan.

## Dependency changes

- Remove 'aws-sdk' ^2.809.0 (in maintenance mode since late 2024;
  end-of-support announced for Nov 2025; emits DEP0169 on url.parse()
  in modern Node).
- Add '@aws-sdk/client-ec2' 3.1033.0 pinned exact. Per-service package
  is dramatically smaller than v2's monolithic bundle.
- Bump '@vercel/ncc' 0.25.1 -> 0.38.4. The old ncc couldn't parse
  modern JS (private class fields in v3's transitive deps); 0.38 is
  webpack-5-based and handles current syntax.

## Code changes (src/aws.js)

Rewrite on the EC2Client + Command pattern:

- EC2Client({}) replaces 'new AWS.EC2()'. Reads region + creds from
  env (same behavior, same source — configure-aws-credentials or
  instance profile).
- client.send(new DescribeImagesCommand(params)) replaces
  ec2.describeImages(params).promise().
- client.send(new RunInstancesCommand(params)) replaces
  ec2.runInstances(params).promise().
- client.send(new TerminateInstancesCommand(params)) replaces
  ec2.terminateInstances(params).promise().
- client.send(new AssociateAddressCommand(params)) replaces
  ec2.associateAddress(params).promise().
- waitUntilInstanceRunning({client, maxWaitTime: 300}, {InstanceIds})
  replaces ec2.waitFor('instanceRunning', ...).promise().

External action contract (inputs + outputs) is unchanged. Consumer
workflows (notably terraform-provider-namecheap) do not need any
change beyond rotating their SHA pin.

## Bundle + CI

- 'npm run package' no longer needs NODE_OPTIONS=--openssl-legacy-provider
  (ncc 0.38 + webpack 5 don't use the legacy module-hash MD4 path).
- dist/ now contains code-split chunk files (136.index.js, 360.index.js,
  etc.) alongside dist/index.js. All must be committed; the verify-dist
  CI check in pr.yml is broadened to diff the whole dist/ tree.
- Bundle size: 7.9 MB -> 3.4 MB main (+ ~3.3 MB in chunks). Net smaller
  than v2.

## Backward compatibility

The DEP0169 process.emitWarning filter added in #6 stays in place.
The v3 bundle doesn't emit DEP0169, so the filter is effectively inert
on the current tip — cleanup is a follow-up, not part of this PR's scope.

## Verification

- npm test: 21 tests pass across tests/utils.test.js + tests/config.test.js
  (no aws.js tests yet; those land as Phase 8.b after Phase 4/5 stop
  rewriting aws.js).
- npm run lint: clean.
- Bundle builds cleanly on Node 20 without OpenSSL legacy provider.

Signed-off-by: yuriyryabikov <22548029+kurok@users.noreply.github.com>

* chore: add .gitattributes to normalize line endings in dist/

ncc 0.38's output contains 451 source-embedded CR bytes inside string
literals (aws-sdk transitive deps). When dist/ is committed through
git's default line-ending normalization, those CRs are stripped into
the blob, but every subsequent 'npm run package' reproduces them —
creating a permanent, symmetric 451/451 diff that the verify-dist CI
gate correctly flagged as drift.

Mark the whole dist/ tree as binary via .gitattributes so git never
converts line endings in that path. What ncc writes is what git
stores; CI's rebuild produces byte-identical output.

Signed-off-by: yuriyryabikov <22548029+kurok@users.noreply.github.com>

---------

Signed-off-by: yuriyryabikov <22548029+kurok@users.noreply.github.com>
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 this pull request may close these issues.

1 participant