From 225a12c2d7ebf5ffe22ffbdf00235794a05d605a Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Sun, 6 Oct 2024 16:17:09 +0200 Subject: [PATCH 1/3] test: remove test for issue 1670 --- test/issue-1670.js | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 test/issue-1670.js diff --git a/test/issue-1670.js b/test/issue-1670.js deleted file mode 100644 index 26904d4da8f..00000000000 --- a/test/issue-1670.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict' - -const { test } = require('node:test') -const { request } = require('..') - -test('https://github.com/mcollina/undici/issues/1670', async () => { - const { body } = await request('https://api.github.com/user/emails') - - await body.text() -}) From d1d441f6a36d2b016a8075073e28ad3e6e49db76 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Sun, 6 Oct 2024 17:41:06 +0200 Subject: [PATCH 2/3] fix another test --- test/node-fetch/main.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/test/node-fetch/main.js b/test/node-fetch/main.js index 4b584281ab6..1473caf198c 100644 --- a/test/node-fetch/main.js +++ b/test/node-fetch/main.js @@ -23,6 +23,8 @@ const HeadersOrig = require('../../lib/web/fetch/headers.js').Headers const ResponseOrig = require('../../lib/web/fetch/response.js').Response const RequestOrig = require('../../lib/web/fetch/request.js').Request const TestServer = require('./utils/server.js') +const { createServer } = require('node:http') +const { default: tspl } = require('@matteo.collina/tspl') const { Uint8Array: VMUint8Array @@ -1617,15 +1619,23 @@ describe('node-fetch', () => { }) }) - it('should support http request', { timeout: 5000 }, function () { - const url = 'https://github.com/' - const options = { - method: 'HEAD' - } - return fetch(url, options).then(res => { - assert.strictEqual(res.status, 200) - assert.strictEqual(res.ok, true) + it('should support http request', { timeout: 5000 }, async function (t) { + t = tspl(t, { plan: 2 }) + const server = createServer((req, res) => { + res.end() + }) + after(() => server.close()) + server.listen(0, () => { + const url = `http://localhost:${server.address().port}` + const options = { + method: 'HEAD' + } + fetch(url, options).then(res => { + t.strictEqual(res.status, 200) + t.strictEqual(res.ok, true) + }) }) + await t.completed }) it('should encode URLs as UTF-8', async () => { From 406122d6a284583bb1448a6a7d1c7c663aefd3ec Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Sun, 6 Oct 2024 17:48:09 +0200 Subject: [PATCH 3/3] add esbuild as devDependency --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 12c47f46824..dfb2dea12be 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "main": "index.js", "types": "index.d.ts", "scripts": { - "build:node": "npx esbuild@0.19.10 index-fetch.js --bundle --platform=node --outfile=undici-fetch.js --define:esbuildDetection=1 --keep-names && node scripts/strip-comments.js", + "build:node": "esbuild index-fetch.js --bundle --platform=node --outfile=undici-fetch.js --define:esbuildDetection=1 --keep-names && node scripts/strip-comments.js", "prebuild:wasm": "node build/wasm.js --prebuild", "build:wasm": "node build/wasm.js --docker", "generate-pem": "node scripts/generate-pem.js", @@ -111,6 +111,7 @@ "c8": "^10.0.0", "cross-env": "^7.0.3", "dns-packet": "^5.4.0", + "esbuild": "^0.19.10", "eslint": "^9.9.0", "fast-check": "^3.17.1", "https-pem": "^3.0.0",