Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit 1c5c294

Browse files
syuilokakkokari-gtyih
authored andcommitted
fix(backend): fix type errors caused by dependency update
https: //github.com/misskey-dev/pull/16308 Co-Authored-By: γ‹γ£γ“γ‹γ‚Š <67428053+kakkokari-gtyih@users.noreply.github.com>
1 parent a88d5c8 commit 1c5c294

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

β€Žpackages/backend/package.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"feed": "4.2.2",
119119
"file-type": "19.6.0",
120120
"fluent-ffmpeg": "2.1.3",
121-
"form-data": "4.0.3",
121+
"form-data": "4.0.4",
122122
"got": "14.4.7",
123123
"happy-dom": "16.8.1",
124124
"hpagent": "1.2.0",

β€Žpackages/backend/src/core/HttpRequestService.tsβ€Ž

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import * as http from 'node:http';
77
import * as https from 'node:https';
88
import * as net from 'node:net';
9+
import * as stream from 'node:stream';
910
import ipaddr from 'ipaddr.js';
1011
import CacheableLookup from 'cacheable-lookup';
1112
import fetch from 'node-fetch';
@@ -26,12 +27,6 @@ export type HttpRequestSendOptions = {
2627
validators?: ((res: Response) => void)[];
2728
};
2829

29-
declare module 'node:http' {
30-
interface Agent {
31-
createConnection(options: net.NetConnectOpts, callback?: (err: Error | null, stream: net.Socket) => void): net.Socket;
32-
}
33-
}
34-
3530
class HttpRequestServiceAgent extends http.Agent {
3631
constructor(
3732
private config: Config,
@@ -41,11 +36,11 @@ class HttpRequestServiceAgent extends http.Agent {
4136
}
4237

4338
@bindThis
44-
public createConnection(options: net.NetConnectOpts, callback?: (err: Error | null, stream: net.Socket) => void): net.Socket {
39+
public createConnection(options: http.ClientRequestArgs, callback?: (err: Error | null, stream: stream.Duplex) => void): stream.Duplex {
4540
const socket = super.createConnection(options, callback)
4641
.on('connect', () => {
47-
const address = socket.remoteAddress;
48-
if (process.env.NODE_ENV === 'production') {
42+
if (socket instanceof net.Socket && process.env.NODE_ENV === 'production') {
43+
const address = socket.remoteAddress;
4944
if (address && ipaddr.isValid(address)) {
5045
if (this.isPrivateIp(address)) {
5146
socket.destroy(new Error(`Blocked address: ${address}`));
@@ -80,11 +75,11 @@ class HttpsRequestServiceAgent extends https.Agent {
8075
}
8176

8277
@bindThis
83-
public createConnection(options: net.NetConnectOpts, callback?: (err: Error | null, stream: net.Socket) => void): net.Socket {
78+
public createConnection(options: http.ClientRequestArgs, callback?: (err: Error | null, stream: stream.Duplex) => void): stream.Duplex {
8479
const socket = super.createConnection(options, callback)
8580
.on('connect', () => {
86-
const address = socket.remoteAddress;
87-
if (process.env.NODE_ENV === 'production') {
81+
if (socket instanceof net.Socket && process.env.NODE_ENV === 'production') {
82+
const address = socket.remoteAddress;
8883
if (address && ipaddr.isValid(address)) {
8984
if (this.isPrivateIp(address)) {
9085
socket.destroy(new Error(`Blocked address: ${address}`));

0 commit comments

Comments
Β (0)