diff options
| author | renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> | 2025-10-04 15:04:28 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-04 15:04:28 +0900 |
| commit | a393d5a87e2bf8de2999f599f6312397c795e1c3 (patch) | |
| tree | 57ae2437cc2c090a490122693271610097814166 /packages/backend/src/core | |
| parent | Bump version to 2025.10.0 in CHANGELOG (diff) | |
| download | misskey-a393d5a87e2bf8de2999f599f6312397c795e1c3.tar.gz misskey-a393d5a87e2bf8de2999f599f6312397c795e1c3.tar.bz2 misskey-a393d5a87e2bf8de2999f599f6312397c795e1c3.zip | |
fix(deps): update [backend] update dependencies (#16547)
* fix(deps): update [backend] update dependencies
* chore: update typeorm.patch
* fix: handle socket creation failure in HttpRequestServiceAgent
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: anatawa12 <anatawa12@icloud.com>
Co-authored-by: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src/core')
| -rw-r--r-- | packages/backend/src/core/HttpRequestService.ts | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/packages/backend/src/core/HttpRequestService.ts b/packages/backend/src/core/HttpRequestService.ts index f7973cbb66..5714bde8bf 100644 --- a/packages/backend/src/core/HttpRequestService.ts +++ b/packages/backend/src/core/HttpRequestService.ts @@ -37,17 +37,23 @@ class HttpRequestServiceAgent extends http.Agent { @bindThis public createConnection(options: http.ClientRequestArgs, callback?: (err: Error | null, stream: stream.Duplex) => void): stream.Duplex { - const socket = super.createConnection(options, callback) - .on('connect', () => { - if (socket instanceof net.Socket && process.env.NODE_ENV === 'production') { - const address = socket.remoteAddress; - if (address && ipaddr.isValid(address)) { - if (this.isPrivateIp(address)) { - socket.destroy(new Error(`Blocked address: ${address}`)); - } + const socket = super.createConnection(options, callback); + + if (socket == null) { + throw new Error('Failed to create socket'); + } + + socket.on('connect', () => { + if (socket instanceof net.Socket && process.env.NODE_ENV === 'production') { + const address = socket.remoteAddress; + if (address && ipaddr.isValid(address)) { + if (this.isPrivateIp(address)) { + socket.destroy(new Error(`Blocked address: ${address}`)); } } - }); + } + }); + return socket; } @@ -76,17 +82,23 @@ class HttpsRequestServiceAgent extends https.Agent { @bindThis public createConnection(options: http.ClientRequestArgs, callback?: (err: Error | null, stream: stream.Duplex) => void): stream.Duplex { - const socket = super.createConnection(options, callback) - .on('connect', () => { - if (socket instanceof net.Socket && process.env.NODE_ENV === 'production') { - const address = socket.remoteAddress; - if (address && ipaddr.isValid(address)) { - if (this.isPrivateIp(address)) { - socket.destroy(new Error(`Blocked address: ${address}`)); - } + const socket = super.createConnection(options, callback); + + if (socket == null) { + throw new Error('Failed to create socket'); + } + + socket.on('connect', () => { + if (socket instanceof net.Socket && process.env.NODE_ENV === 'production') { + const address = socket.remoteAddress; + if (address && ipaddr.isValid(address)) { + if (this.isPrivateIp(address)) { + socket.destroy(new Error(`Blocked address: ${address}`)); } } - }); + } + }); + return socket; } |