diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 4c3a77ec1e3..f75295fea02 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -23,14 +23,6 @@ jobs: post-test-steps: | - name: Coverage Report uses: codecov/codecov-action@v3 - include: | - - runs-on: ubuntu-latest - node-version: 16.8 - exclude: | - - runs-on: windows-latest - node-version: 14 - - runs-on: windows-latest - node-version: 16 automerge: if: > github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' diff --git a/index.js b/index.js index 26302cc8efa..66d60785613 100644 --- a/index.js +++ b/index.js @@ -98,58 +98,54 @@ function makeDispatcher (fn) { module.exports.setGlobalDispatcher = setGlobalDispatcher module.exports.getGlobalDispatcher = getGlobalDispatcher -if (util.nodeMajor > 16 || (util.nodeMajor === 16 && util.nodeMinor >= 8)) { - let fetchImpl = null - module.exports.fetch = async function fetch (resource) { - if (!fetchImpl) { - fetchImpl = require('./lib/fetch').fetch - } - - try { - return await fetchImpl(...arguments) - } catch (err) { - if (typeof err === 'object') { - Error.captureStackTrace(err, this) - } +let fetchImpl = null +module.exports.fetch = async function fetch (resource) { + if (!fetchImpl) { + fetchImpl = require('./lib/fetch').fetch + } - throw err + try { + return await fetchImpl(...arguments) + } catch (err) { + if (typeof err === 'object') { + Error.captureStackTrace(err, this) } + + throw err } - module.exports.Headers = require('./lib/fetch/headers').Headers - module.exports.Response = require('./lib/fetch/response').Response - module.exports.Request = require('./lib/fetch/request').Request - module.exports.FormData = require('./lib/fetch/formdata').FormData - module.exports.File = require('./lib/fetch/file').File - module.exports.FileReader = require('./lib/fileapi/filereader').FileReader +} +module.exports.Headers = require('./lib/fetch/headers').Headers +module.exports.Response = require('./lib/fetch/response').Response +module.exports.Request = require('./lib/fetch/request').Request +module.exports.FormData = require('./lib/fetch/formdata').FormData +module.exports.File = require('./lib/fetch/file').File +module.exports.FileReader = require('./lib/fileapi/filereader').FileReader - const { setGlobalOrigin, getGlobalOrigin } = require('./lib/fetch/global') +const { setGlobalOrigin, getGlobalOrigin } = require('./lib/fetch/global') - module.exports.setGlobalOrigin = setGlobalOrigin - module.exports.getGlobalOrigin = getGlobalOrigin +module.exports.setGlobalOrigin = setGlobalOrigin +module.exports.getGlobalOrigin = getGlobalOrigin - const { CacheStorage } = require('./lib/cache/cachestorage') - const { kConstruct } = require('./lib/cache/symbols') +const { CacheStorage } = require('./lib/cache/cachestorage') +const { kConstruct } = require('./lib/cache/symbols') - // Cache & CacheStorage are tightly coupled with fetch. Even if it may run - // in an older version of Node, it doesn't have any use without fetch. - module.exports.caches = new CacheStorage(kConstruct) -} +// Cache & CacheStorage are tightly coupled with fetch. Even if it may run +// in an older version of Node, it doesn't have any use without fetch. +module.exports.caches = new CacheStorage(kConstruct) -if (util.nodeMajor >= 16) { - const { deleteCookie, getCookies, getSetCookies, setCookie } = require('./lib/cookies') +const { deleteCookie, getCookies, getSetCookies, setCookie } = require('./lib/cookies') - module.exports.deleteCookie = deleteCookie - module.exports.getCookies = getCookies - module.exports.getSetCookies = getSetCookies - module.exports.setCookie = setCookie +module.exports.deleteCookie = deleteCookie +module.exports.getCookies = getCookies +module.exports.getSetCookies = getSetCookies +module.exports.setCookie = setCookie - const { parseMIMEType, serializeAMimeType } = require('./lib/fetch/dataURL') +const { parseMIMEType, serializeAMimeType } = require('./lib/fetch/dataURL') - module.exports.parseMIMEType = parseMIMEType - module.exports.serializeAMimeType = serializeAMimeType -} +module.exports.parseMIMEType = parseMIMEType +module.exports.serializeAMimeType = serializeAMimeType -if (util.nodeMajor >= 18 && hasCrypto) { +if (hasCrypto) { const { WebSocket } = require('./lib/websocket/websocket') module.exports.WebSocket = WebSocket diff --git a/lib/core/request.js b/lib/core/request.js index 3697e6a3acc..b0bd870e33a 100644 --- a/lib/core/request.js +++ b/lib/core/request.js @@ -196,10 +196,6 @@ class Request { } if (util.isFormDataLike(this.body)) { - if (util.nodeMajor < 16 || (util.nodeMajor === 16 && util.nodeMinor < 8)) { - throw new InvalidArgumentError('Form-Data bodies are only supported in node v16.8 and newer.') - } - if (!extractBody) { extractBody = require('../fetch/body.js').extractBody } diff --git a/package.json b/package.json index 2b64daf41e2..724bb088408 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ "ws": "^8.11.0" }, "engines": { - "node": ">=14.0" + "node": ">=18.0" }, "standard": { "env": [