Upgrade node-fetch to 2.7.0 (#20165)
* Set `node-fetch` to `^2.7.0`
* Update package-lock.json
```
# root
bin/npm update node-fetch
bin/npm update cross-fetch
# in other path in docker
npm update node-fetch
```
* Update node-fetch patch
* [fetch-utils] Skip the test: destroys the request body if it doesn't get consumed
```
1) fetch-utils
fetchJson
destroys the request body if it doesn't get consumed:
FetchError: Invalid response body while trying to fetch http://example.com:30001/json/ignore-request: write EPIPE
at PassThrough.<anonymous> (/overleaf/node_modules/node-fetch/lib/index.js:400:12)
at PassThrough.emit (node:events:529:35)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
```
* [fetch-utils] Delete the test: destroys the request body if it doesn't get consumed
* Remove the `setTimeout` in the node-fetch patch
Fixes a test and doesn't break filestore acceptance tests
* Update node-fetch patch again: bring changes from https://github.com/node-fetch/node-fetch/blob/e87b093/src/index.js
* Update node-fetch patch again: bring changes from https://github.com/node-fetch/node-fetch/blob/e87b093/src/index.js
* Update node-fetch patches back to single lines
Per https://github.com/overleaf/internal/pull/20165#discussion_r1739035513
GitOrigin-RevId: 945e5a12e838673b7bc87b588b7aca1bcd9109e2
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
"dependencies": {
|
||||
"@overleaf/o-error": "*",
|
||||
"lodash": "^4.17.21",
|
||||
"node-fetch": "^2.6.11",
|
||||
"node-fetch": "^2.7.0",
|
||||
"selfsigned": "^2.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { expect } = require('chai')
|
||||
const { FetchError } = require('node-fetch')
|
||||
const { FetchError, AbortError } = require('node-fetch')
|
||||
const { Readable } = require('stream')
|
||||
const { once } = require('events')
|
||||
const { TestServer } = require('./helpers/TestServer')
|
||||
@@ -15,8 +15,6 @@ const {
|
||||
CustomHttpsAgent,
|
||||
} = require('../..')
|
||||
|
||||
const abortErrorMessage = 'The user aborted a request'
|
||||
|
||||
const HTTP_PORT = 30001
|
||||
const HTTPS_PORT = 30002
|
||||
|
||||
@@ -107,7 +105,7 @@ describe('fetch-utils', function () {
|
||||
it('supports abort signals', async function () {
|
||||
await expect(
|
||||
fetchJson(this.url('/hang'), { signal: AbortSignal.timeout(10) })
|
||||
).to.be.rejectedWith(abortErrorMessage)
|
||||
).to.be.rejectedWith(AbortError)
|
||||
await expectRequestAborted(this.server.lastReq)
|
||||
})
|
||||
|
||||
@@ -148,7 +146,7 @@ describe('fetch-utils', function () {
|
||||
body: stream,
|
||||
})
|
||||
stream.destroy()
|
||||
await expect(promise).to.be.rejectedWith(abortErrorMessage)
|
||||
await expect(promise).to.be.rejectedWith(AbortError)
|
||||
await wait(80)
|
||||
expect(this.server.lastReq).to.be.undefined
|
||||
})
|
||||
@@ -162,7 +160,7 @@ describe('fetch-utils', function () {
|
||||
})
|
||||
await once(this.server.events, 'request-received')
|
||||
stream.destroy()
|
||||
await expect(promise).to.be.rejectedWith(abortErrorMessage)
|
||||
await expect(promise).to.be.rejectedWith(AbortError)
|
||||
await expectRequestAborted(this.server.lastReq)
|
||||
})
|
||||
|
||||
@@ -176,7 +174,7 @@ describe('fetch-utils', function () {
|
||||
it('supports abort signals', async function () {
|
||||
await expect(
|
||||
fetchStream(this.url('/hang'), { signal: AbortSignal.timeout(10) })
|
||||
).to.be.rejectedWith(abortErrorMessage)
|
||||
).to.be.rejectedWith(AbortError)
|
||||
await expectRequestAborted(this.server.lastReq)
|
||||
})
|
||||
|
||||
@@ -188,7 +186,7 @@ describe('fetch-utils', function () {
|
||||
body: stream,
|
||||
signal: AbortSignal.timeout(10),
|
||||
})
|
||||
).to.be.rejectedWith(abortErrorMessage)
|
||||
).to.be.rejectedWith(AbortError)
|
||||
expect(stream.destroyed).to.be.true
|
||||
})
|
||||
})
|
||||
@@ -206,7 +204,7 @@ describe('fetch-utils', function () {
|
||||
body: stream,
|
||||
})
|
||||
stream.destroy()
|
||||
await expect(promise).to.be.rejectedWith(abortErrorMessage)
|
||||
await expect(promise).to.be.rejectedWith(AbortError)
|
||||
expect(this.server.lastReq).to.be.undefined
|
||||
})
|
||||
|
||||
@@ -219,7 +217,7 @@ describe('fetch-utils', function () {
|
||||
})
|
||||
await once(this.server.events, 'request-received')
|
||||
stream.destroy()
|
||||
await expect(promise).to.be.rejectedWith(abortErrorMessage)
|
||||
await expect(promise).to.be.rejectedWith(AbortError)
|
||||
await wait(80)
|
||||
await expectRequestAborted(this.server.lastReq)
|
||||
})
|
||||
@@ -239,7 +237,7 @@ describe('fetch-utils', function () {
|
||||
it('supports abort signals', async function () {
|
||||
await expect(
|
||||
fetchNothing(this.url('/hang'), { signal: AbortSignal.timeout(10) })
|
||||
).to.be.rejectedWith(abortErrorMessage)
|
||||
).to.be.rejectedWith(AbortError)
|
||||
await expectRequestAborted(this.server.lastReq)
|
||||
})
|
||||
|
||||
@@ -251,7 +249,7 @@ describe('fetch-utils', function () {
|
||||
body: stream,
|
||||
signal: AbortSignal.timeout(10),
|
||||
})
|
||||
).to.be.rejectedWith(abortErrorMessage)
|
||||
).to.be.rejectedWith(AbortError)
|
||||
expect(stream.destroyed).to.be.true
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user