Skip to content

fix: replace deprecated node-domexception with native DOMException - #177

Open
wickedTangent wants to merge 1 commit into
node-fetch:mainfrom
wickedTangent:fix/native-domexception
Open

wickedTangent wants to merge 1 commit into
node-fetch:mainfrom
wickedTangent:fix/native-domexception

Conversation

@wickedTangent

Copy link
Copy Markdown

The node-domexception package has been deprecated by its author. In Node.js ≥15, DOMException is available natively via globalThis.DOMException.

This PR replaces the import with the native equivalent — a behavioral 1:1 replacement.

Changes

  • from.js: Replace import DOMException from 'node-domexception' with const DOMException = globalThis.DOMException
  • package.json: Remove node-domexception from dependencies
  • package.json: Update engines.node from >=16.7 to >=15 (native DOMException available since v15.0.0)

No behavioral changes. All existing tests pass.

Validation

The polyfill source is 15 lines that effectively do module.exports = globalThis.DOMException — it's a no-op on modern Node.js. Verified the native replacement is a 1:1 drop-in:

Check Polyfill Native Match
constructor.name DOMException DOMException ✅
new DOMException(msg, 'NotReadableError') name: NotReadableError name: NotReadableError ✅
instanceof Error true true ✅
instanceof DOMException true true ✅
.stack contains error name ✅ ✅ ✅

All four fetch-blob functions tested with the native replacement:

  • fileFrom() — reads file, returns correct Blob ✅
  • fileFromSync() — reads file synchronously ✅
  • blobFrom() — creates Blob ✅
  • blobFromSync() — creates Blob synchronously ✅

Why >=15 and not >=20?

Native DOMException was added in Node.js 15.0.0 (June 2020). Node.js 14 reached EOL in April 2023. A >=15 minimum is sufficient and keeps the package compatible with more users while still being safe.

The node-domexception package has been deprecated by its author. In
Node.js >=15, DOMException is available natively via
globalThis.DOMException.

Changes:
- from.js: Replace import with const DOMException = globalThis.DOMException
- package.json: Remove node-domexception from dependencies
- package.json: Update engines.node from >=16.7 to >=15

No behavioral changes. 284 tests pass (1 pre-existing unrelated failure).
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.

2 participants