From 65f798116b5f4971285e996db295f51ba0479b3a Mon Sep 17 00:00:00 2001 From: "Stanley (QXU)" Date: Sat, 30 Mar 2024 21:25:45 +0800 Subject: [PATCH] Unidici is failing for Node 14. Another try with node-fetch@2 --- package.json | 4 ++-- test/issue-288.test.js | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 6726127..5322d9c 100644 --- a/package.json +++ b/package.json @@ -23,11 +23,11 @@ "adm-zip": "^0.5.10", "fastify": "^4.19.2", "jsonstream": "^1.0.3", + "node-fetch": "2", "standard": "^17.1.0", "tap": "^16.3.7", "tsd": "^0.30.0", - "typescript": "^5.1.6", - "undici": "^6.10.2" + "typescript": "^5.1.6" }, "scripts": { "coverage": "npm run test:unit -- --coverage-report=html", diff --git a/test/issue-288.test.js b/test/issue-288.test.js index 1ad5d60..d050581 100644 --- a/test/issue-288.test.js +++ b/test/issue-288.test.js @@ -3,12 +3,7 @@ const { test } = require('tap') const Fastify = require('fastify') const fastifyCompress = require('..') -const { request, setGlobalDispatcher, Agent } = require('undici') - -setGlobalDispatcher(new Agent({ - keepAliveTimeout: 10, - keepAliveMaxTimeout: 10 -})) +const fetch = require('node-fetch') test('should not corrupt the file content', async (t) => { // provide 2 byte unicode content @@ -37,10 +32,10 @@ test('should not corrupt the file content', async (t) => { const address = await fastify.listen({ port: 0, host: '127.0.0.1' }) - const response1 = await request(`${address}/compress`) - const response2 = await request(`${address}/no-compress`) - const body1 = await response1.body.text() - const body2 = await response2.body.text() + const response1 = await fetch(`${address}/compress`) + const response2 = await fetch(`${address}/no-compress`) + const body1 = await response1.text() + const body2 = await response2.text() t.equal(body1, body2) t.equal(body1.length, twoByteUnicodeContent.length) t.equal(body2.length, twoByteUnicodeContent.length)