@subsquid/http-client 1.7.0-2-0.3887d2 → 1.7.0-portal-api.d887ad
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm.d.ts +2 -0
- package/esm.js +3 -0
- package/lib/agent.d.ts +15 -0
- package/lib/agent.d.ts.map +1 -0
- package/lib/agent.js +57 -0
- package/lib/agent.js.map +1 -0
- package/lib/client.d.ts +5 -14
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +49 -71
- package/lib/client.js.map +1 -1
- package/lib/client.test.d.ts +2 -0
- package/lib/client.test.d.ts.map +1 -0
- package/lib/client.test.js +14 -0
- package/lib/client.test.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/request.d.ts +9 -0
- package/lib/request.d.ts.map +1 -0
- package/lib/request.js +32 -0
- package/lib/request.js.map +1 -0
- package/package.json +6 -5
- package/src/agent.ts +39 -0
- package/src/client.test.ts +10 -0
- package/src/client.ts +94 -129
- package/src/index.ts +1 -0
- package/src/request.ts +29 -0
package/esm.d.ts
ADDED
package/esm.js
ADDED
package/lib/agent.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import * as https from 'https';
|
|
3
|
+
export interface AgentProvider {
|
|
4
|
+
getNativeAgent(url: string): http.Agent;
|
|
5
|
+
}
|
|
6
|
+
export declare const defaultAgentProvider: AgentProvider;
|
|
7
|
+
export declare class HttpAgent implements AgentProvider {
|
|
8
|
+
private options;
|
|
9
|
+
private http?;
|
|
10
|
+
private https?;
|
|
11
|
+
constructor(options: https.AgentOptions);
|
|
12
|
+
getNativeAgent(url: string): http.Agent;
|
|
13
|
+
close(): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,MAAM,WAAW,aAAa;IAC1B,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,KAAK,CAAA;CAC1C;AAGD,eAAO,MAAM,oBAAoB,EAAE,aAQlC,CAAA;AAGD,qBAAa,SAAU,YAAW,aAAa;IAI/B,OAAO,CAAC,OAAO;IAH3B,OAAO,CAAC,IAAI,CAAC,CAAY;IACzB,OAAO,CAAC,KAAK,CAAC,CAAa;gBAEP,OAAO,EAAE,KAAK,CAAC,YAAY;IAE/C,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,KAAK;IAQvC,KAAK;CAIR"}
|
package/lib/agent.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.HttpAgent = exports.defaultAgentProvider = void 0;
|
|
27
|
+
const http = __importStar(require("http"));
|
|
28
|
+
const https = __importStar(require("https"));
|
|
29
|
+
exports.defaultAgentProvider = {
|
|
30
|
+
getNativeAgent(url) {
|
|
31
|
+
if (url.startsWith('https://')) {
|
|
32
|
+
return https.globalAgent;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return http.globalAgent;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
class HttpAgent {
|
|
40
|
+
constructor(options) {
|
|
41
|
+
this.options = options;
|
|
42
|
+
}
|
|
43
|
+
getNativeAgent(url) {
|
|
44
|
+
if (url.startsWith('https://')) {
|
|
45
|
+
return this.https || (this.https = new https.Agent(this.options));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return this.http || (this.http = new http.Agent(this.options));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
close() {
|
|
52
|
+
this.http?.destroy();
|
|
53
|
+
this.https?.destroy();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.HttpAgent = HttpAgent;
|
|
57
|
+
//# sourceMappingURL=agent.js.map
|
package/lib/agent.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAC5B,6CAA8B;AAQjB,QAAA,oBAAoB,GAAkB;IAC/C,cAAc,CAAC,GAAW;QACtB,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC,WAAW,CAAA;QAC5B,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,WAAW,CAAA;QAC3B,CAAC;IACL,CAAC;CACJ,CAAA;AAGD,MAAa,SAAS;IAIlB,YAAoB,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;IAAG,CAAC;IAEnD,cAAc,CAAC,GAAW;QACtB,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QACrE,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAClE,CAAC;IACL,CAAC;IAED,KAAK;QACD,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAA;QACpB,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAA;IACzB,CAAC;CACJ;AAlBD,8BAkBC"}
|
package/lib/client.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Logger } from '@subsquid/logger';
|
|
2
|
+
import type { Headers, RequestInit, Response } from 'node-fetch';
|
|
3
|
+
import { AgentProvider } from './agent';
|
|
2
4
|
import { HttpBody } from './body';
|
|
3
5
|
export { HttpBody };
|
|
4
6
|
export interface HttpClientOptions {
|
|
7
|
+
agent?: AgentProvider;
|
|
5
8
|
baseUrl?: string;
|
|
6
9
|
headers?: Record<string, string | number | bigint>;
|
|
7
10
|
/**
|
|
@@ -11,12 +14,9 @@ export interface HttpClientOptions {
|
|
|
11
14
|
* Overall request processing time might be much larger due to retries.
|
|
12
15
|
*/
|
|
13
16
|
httpTimeout?: number;
|
|
14
|
-
bodyTimeout?: number;
|
|
15
17
|
retryAttempts?: number;
|
|
16
18
|
retrySchedule?: number[];
|
|
17
|
-
keepalive?: boolean;
|
|
18
19
|
log?: Logger | null;
|
|
19
|
-
fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
20
20
|
}
|
|
21
21
|
export interface RequestOptions {
|
|
22
22
|
query?: Record<string, string | number | bigint>;
|
|
@@ -24,10 +24,8 @@ export interface RequestOptions {
|
|
|
24
24
|
retryAttempts?: number;
|
|
25
25
|
retrySchedule?: number[];
|
|
26
26
|
httpTimeout?: number;
|
|
27
|
-
bodyTimeout?: number;
|
|
28
27
|
abort?: AbortSignal;
|
|
29
28
|
stream?: boolean;
|
|
30
|
-
keepalive?: boolean;
|
|
31
29
|
}
|
|
32
30
|
export interface GraphqlRequestOptions extends RequestOptions {
|
|
33
31
|
variables?: Record<string, any>;
|
|
@@ -40,7 +38,6 @@ export interface FetchRequest extends RequestInit {
|
|
|
40
38
|
url: string;
|
|
41
39
|
headers: Headers;
|
|
42
40
|
timeout?: number;
|
|
43
|
-
bodyTimeout?: number;
|
|
44
41
|
signal?: AbortSignal;
|
|
45
42
|
stream?: boolean;
|
|
46
43
|
}
|
|
@@ -49,13 +46,11 @@ export declare class HttpClient {
|
|
|
49
46
|
protected log?: Logger;
|
|
50
47
|
protected headers?: Record<string, string | number | bigint>;
|
|
51
48
|
private baseUrl?;
|
|
49
|
+
private agent;
|
|
52
50
|
private retrySchedule;
|
|
53
51
|
private retryAttempts;
|
|
54
52
|
private httpTimeout;
|
|
55
|
-
private bodyTimeout?;
|
|
56
53
|
private requestCounter;
|
|
57
|
-
private keepalive?;
|
|
58
|
-
private fetch;
|
|
59
54
|
constructor(options?: HttpClientOptions);
|
|
60
55
|
get<T = any>(url: string, options?: RequestOptions): Promise<T>;
|
|
61
56
|
post<T = any>(url: string, options?: RequestOptions & HttpBody): Promise<T>;
|
|
@@ -102,10 +97,6 @@ export declare class HttpTimeoutError extends Error {
|
|
|
102
97
|
constructor(ms: number);
|
|
103
98
|
get name(): string;
|
|
104
99
|
}
|
|
105
|
-
export declare class HttpBodyTimeoutError extends Error {
|
|
106
|
-
constructor(ms: number);
|
|
107
|
-
get name(): string;
|
|
108
|
-
}
|
|
109
100
|
export interface GraphqlMessage {
|
|
110
101
|
message: string;
|
|
111
102
|
path?: (string | number)[];
|
|
@@ -115,6 +106,6 @@ export declare class GraphqlError extends Error {
|
|
|
115
106
|
constructor(messages: GraphqlMessage[]);
|
|
116
107
|
get name(): string;
|
|
117
108
|
}
|
|
109
|
+
export declare function isHttpConnectionError(err: unknown): boolean;
|
|
118
110
|
export declare function asRetryAfterPause(res: HttpResponse | Error): number | undefined;
|
|
119
|
-
export declare function isHttpConnectionError(error: unknown): boolean;
|
|
120
111
|
//# sourceMappingURL=client.d.ts.map
|
package/lib/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AAG5C,OAAO,KAAK,EAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAC,aAAa,EAAuB,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAA;AAK/B,OAAO,EAAC,QAAQ,EAAC,CAAA;AAGjB,MAAM,WAAW,iBAAiB;IAC9B,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,CAAA;IAClD;;;;;O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,EAAE,cAAc,EAAE;gBAA1B,QAAQ,EAAE,cAAc,EAAE;IAItD,IAAI,IAAI,IAAI,MAAM,CAEjB;CACJ;AAGD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAS3D;AAGD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAY/E"}
|
package/lib/client.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GraphqlError = exports.
|
|
4
|
-
exports.asRetryAfterPause = asRetryAfterPause;
|
|
3
|
+
exports.GraphqlError = exports.HttpTimeoutError = exports.HttpError = exports.HttpResponse = exports.HttpClient = void 0;
|
|
5
4
|
exports.isHttpConnectionError = isHttpConnectionError;
|
|
5
|
+
exports.asRetryAfterPause = asRetryAfterPause;
|
|
6
|
+
const logger_1 = require("@subsquid/logger");
|
|
6
7
|
const util_internal_1 = require("@subsquid/util-internal");
|
|
7
|
-
const
|
|
8
|
+
const agent_1 = require("./agent");
|
|
9
|
+
const request_1 = require("./request");
|
|
8
10
|
class HttpClient {
|
|
9
11
|
constructor(options = {}) {
|
|
10
12
|
this.requestCounter = 0;
|
|
11
|
-
this.log = options.log === null ? undefined : options.log;
|
|
13
|
+
this.log = options.log === null ? undefined : options.log || (0, logger_1.createLogger)('sqd:http-client');
|
|
12
14
|
this.headers = options.headers;
|
|
13
15
|
this.setBaseUrl(options.baseUrl);
|
|
16
|
+
this.agent = options.agent || agent_1.defaultAgentProvider;
|
|
14
17
|
this.retrySchedule = options.retrySchedule || [10, 100, 500, 2000, 10000, 20000];
|
|
15
18
|
this.retryAttempts = options.retryAttempts || 0;
|
|
16
19
|
this.httpTimeout = options.httpTimeout ?? 20000;
|
|
17
|
-
this.bodyTimeout = options.bodyTimeout;
|
|
18
|
-
this.keepalive = options.keepalive;
|
|
19
|
-
this.fetch = options.fetch || fetch;
|
|
20
20
|
}
|
|
21
21
|
get(url, options) {
|
|
22
|
-
return this.request('GET', url, options).then(
|
|
22
|
+
return this.request('GET', url, options).then(res => res.body);
|
|
23
23
|
}
|
|
24
24
|
post(url, options) {
|
|
25
|
-
return this.request('POST', url, options).then(
|
|
25
|
+
return this.request('POST', url, options).then(res => res.body);
|
|
26
26
|
}
|
|
27
27
|
async request(method, url, options = {}) {
|
|
28
28
|
let req = await this.prepareRequest(method, url, options);
|
|
@@ -36,7 +36,9 @@ class HttpClient {
|
|
|
36
36
|
if (retryAttempts > retries && this.isRetryableError(res, req)) {
|
|
37
37
|
let pause = asRetryAfterPause(res);
|
|
38
38
|
if (pause == null) {
|
|
39
|
-
pause = retrySchedule.length
|
|
39
|
+
pause = retrySchedule.length
|
|
40
|
+
? retrySchedule[Math.min(retries, retrySchedule.length - 1)]
|
|
41
|
+
: 1000;
|
|
40
42
|
}
|
|
41
43
|
retries += 1;
|
|
42
44
|
this.beforeRetryPause(req, res, pause);
|
|
@@ -61,7 +63,7 @@ class HttpClient {
|
|
|
61
63
|
httpRequestUrl: req.url,
|
|
62
64
|
httpRequestMethod: req.method,
|
|
63
65
|
httpRequestHeaders: Array.from(req.headers),
|
|
64
|
-
httpRequestBody: req.body
|
|
66
|
+
httpRequestBody: req.body
|
|
65
67
|
}, 'http request');
|
|
66
68
|
}
|
|
67
69
|
}
|
|
@@ -70,8 +72,7 @@ class HttpClient {
|
|
|
70
72
|
let info = {
|
|
71
73
|
httpRequestId: req.id,
|
|
72
74
|
httpRequestUrl: req.url,
|
|
73
|
-
httpRequestMethod: req.method
|
|
74
|
-
httpRequestBody: req.body,
|
|
75
|
+
httpRequestMethod: req.method
|
|
75
76
|
};
|
|
76
77
|
if (reason instanceof Error) {
|
|
77
78
|
info.reason = reason.toString();
|
|
@@ -92,7 +93,7 @@ class HttpClient {
|
|
|
92
93
|
httpRequestId: req.id,
|
|
93
94
|
httpResponseUrl: url,
|
|
94
95
|
httpResponseStatus: status,
|
|
95
|
-
httpResponseHeaders: Array.from(headers)
|
|
96
|
+
httpResponseHeaders: Array.from(headers)
|
|
96
97
|
}, 'http headers');
|
|
97
98
|
}
|
|
98
99
|
}
|
|
@@ -106,21 +107,21 @@ class HttpClient {
|
|
|
106
107
|
}
|
|
107
108
|
this.log.debug({
|
|
108
109
|
httpRequestId: req.id,
|
|
109
|
-
httpResponseBody
|
|
110
|
+
httpResponseBody
|
|
110
111
|
}, 'http body');
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
async prepareRequest(method, url, options) {
|
|
115
|
+
await request_1.nodeFetch.load();
|
|
114
116
|
let req = {
|
|
115
117
|
id: this.requestCounter++,
|
|
116
118
|
method,
|
|
117
|
-
headers: new Headers(options.headers),
|
|
119
|
+
headers: new request_1.nodeFetch.Headers(options.headers),
|
|
118
120
|
url: this.getAbsUrl(url),
|
|
119
121
|
signal: options.abort,
|
|
122
|
+
compress: true,
|
|
120
123
|
timeout: options.httpTimeout ?? this.httpTimeout,
|
|
121
|
-
|
|
122
|
-
stream: options.stream,
|
|
123
|
-
keepalive: options.keepalive ?? this.keepalive,
|
|
124
|
+
stream: options.stream
|
|
124
125
|
};
|
|
125
126
|
this.handleBasicAuth(req);
|
|
126
127
|
if (options.query) {
|
|
@@ -132,6 +133,7 @@ class HttpClient {
|
|
|
132
133
|
req.url += '?' + qs;
|
|
133
134
|
}
|
|
134
135
|
}
|
|
136
|
+
req.agent = this.agent.getNativeAgent(req.url);
|
|
135
137
|
if (options.content !== undefined) {
|
|
136
138
|
if (typeof options.content == 'string') {
|
|
137
139
|
req.body = options.content;
|
|
@@ -139,9 +141,12 @@ class HttpClient {
|
|
|
139
141
|
req.headers.set('content-type', 'text/plain');
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
|
-
else {
|
|
144
|
+
else if (Buffer.isBuffer(options.content)) {
|
|
143
145
|
req.body = options.content;
|
|
144
146
|
}
|
|
147
|
+
else {
|
|
148
|
+
req.body = Buffer.from(options.content.buffer, options.content.byteOffset, options.content.byteLength);
|
|
149
|
+
}
|
|
145
150
|
}
|
|
146
151
|
if (options.json !== undefined) {
|
|
147
152
|
req.body = JSON.stringify(options.json);
|
|
@@ -179,7 +184,7 @@ class HttpClient {
|
|
|
179
184
|
}, req.timeout);
|
|
180
185
|
let res;
|
|
181
186
|
try {
|
|
182
|
-
return
|
|
187
|
+
return res = await this.performRequest({ ...req, signal: ac.signal });
|
|
183
188
|
}
|
|
184
189
|
catch (err) {
|
|
185
190
|
if (timer == null) {
|
|
@@ -190,27 +195,28 @@ class HttpClient {
|
|
|
190
195
|
}
|
|
191
196
|
}
|
|
192
197
|
finally {
|
|
193
|
-
|
|
198
|
+
if (timer != null) {
|
|
199
|
+
clearTimeout(timer);
|
|
200
|
+
}
|
|
194
201
|
req.signal?.removeEventListener('abort', abort);
|
|
195
202
|
}
|
|
196
203
|
}
|
|
197
204
|
async performRequest(req) {
|
|
198
|
-
let res = await
|
|
205
|
+
let res = await request_1.nodeFetch.request(req.url, req);
|
|
199
206
|
this.afterResponseHeaders(req, res.url, res.status, res.headers);
|
|
200
|
-
let
|
|
201
|
-
|
|
207
|
+
let httpResponse;
|
|
208
|
+
if (req.stream && res.ok) {
|
|
209
|
+
httpResponse = new HttpResponse(req.id, res.url, res.status, res.headers, res.body, res.body != null);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
let body = await this.handleResponseBody(req, res);
|
|
213
|
+
httpResponse = new HttpResponse(req.id, res.url, res.status, res.headers, body, false);
|
|
214
|
+
}
|
|
202
215
|
this.afterResponse(req, httpResponse);
|
|
203
216
|
return httpResponse;
|
|
204
217
|
}
|
|
205
218
|
async handleResponseBody(req, res) {
|
|
206
219
|
let contentType = (res.headers.get('content-type') || '').split(';')[0];
|
|
207
|
-
if (req.bodyTimeout != null && res.body != null) {
|
|
208
|
-
let body = (0, util_timeout_1.addStreamTimeout)(res.body, req.bodyTimeout, () => new HttpBodyTimeoutError(req.bodyTimeout));
|
|
209
|
-
res = new Response(body, res);
|
|
210
|
-
}
|
|
211
|
-
if (req.stream && res.ok && res.body != null) {
|
|
212
|
-
return res.body;
|
|
213
|
-
}
|
|
214
220
|
if (contentType == 'application/json') {
|
|
215
221
|
return res.json();
|
|
216
222
|
}
|
|
@@ -220,7 +226,7 @@ class HttpClient {
|
|
|
220
226
|
let arrayBuffer = await res.arrayBuffer();
|
|
221
227
|
if (arrayBuffer.byteLength == 0)
|
|
222
228
|
return undefined;
|
|
223
|
-
return arrayBuffer;
|
|
229
|
+
return Buffer.from(arrayBuffer);
|
|
224
230
|
}
|
|
225
231
|
isRetryableError(error, req) {
|
|
226
232
|
if (isHttpConnectionError(error))
|
|
@@ -297,7 +303,7 @@ class HttpClient {
|
|
|
297
303
|
else {
|
|
298
304
|
req.json = {
|
|
299
305
|
query: gql,
|
|
300
|
-
variables
|
|
306
|
+
variables
|
|
301
307
|
};
|
|
302
308
|
}
|
|
303
309
|
let res = await this.request(method, url, req);
|
|
@@ -332,7 +338,7 @@ class HttpResponse {
|
|
|
332
338
|
status: this.status,
|
|
333
339
|
headers: Array.from(this.headers),
|
|
334
340
|
body: this.stream ? undefined : this.body,
|
|
335
|
-
url: this.url
|
|
341
|
+
url: this.url
|
|
336
342
|
};
|
|
337
343
|
}
|
|
338
344
|
}
|
|
@@ -357,15 +363,6 @@ class HttpTimeoutError extends Error {
|
|
|
357
363
|
}
|
|
358
364
|
}
|
|
359
365
|
exports.HttpTimeoutError = HttpTimeoutError;
|
|
360
|
-
class HttpBodyTimeoutError extends Error {
|
|
361
|
-
constructor(ms) {
|
|
362
|
-
super(`request body timed out after ${ms} ms`);
|
|
363
|
-
}
|
|
364
|
-
get name() {
|
|
365
|
-
return 'HttpBodyTimeoutError';
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
exports.HttpBodyTimeoutError = HttpBodyTimeoutError;
|
|
369
366
|
class GraphqlError extends Error {
|
|
370
367
|
constructor(messages) {
|
|
371
368
|
super(`GraphQL error: ${messages[0].message}`);
|
|
@@ -376,13 +373,14 @@ class GraphqlError extends Error {
|
|
|
376
373
|
}
|
|
377
374
|
}
|
|
378
375
|
exports.GraphqlError = GraphqlError;
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
376
|
+
function isHttpConnectionError(err) {
|
|
377
|
+
return request_1.nodeFetch.isLoaded
|
|
378
|
+
&& err instanceof request_1.nodeFetch.FetchError
|
|
379
|
+
&& err.type == 'system'
|
|
380
|
+
&& (err.message.startsWith('request to') ||
|
|
381
|
+
err.code == 'ERR_STREAM_PREMATURE_CLOSE' ||
|
|
382
|
+
err.code == 'ECONNRESET');
|
|
383
|
+
}
|
|
386
384
|
function asRetryAfterPause(res) {
|
|
387
385
|
if (res instanceof HttpError) {
|
|
388
386
|
res = res.response;
|
|
@@ -399,24 +397,4 @@ function asRetryAfterPause(res) {
|
|
|
399
397
|
return undefined;
|
|
400
398
|
}
|
|
401
399
|
const HTTP_DATE_REGEX = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/;
|
|
402
|
-
// ref: https://github.com/sindresorhus/is-network-error/blob/main/index.js
|
|
403
|
-
const errorMessages = new Set([
|
|
404
|
-
'network error', // Chrome
|
|
405
|
-
'Failed to fetch', // Chrome
|
|
406
|
-
'NetworkError when attempting to fetch resource.', // Firefox
|
|
407
|
-
'The Internet connection appears to be offline.', // Safari 16
|
|
408
|
-
'Load failed', // Safari 17+
|
|
409
|
-
'Network request failed', // `cross-fetch`
|
|
410
|
-
'fetch failed', // Undici (Node.js)
|
|
411
|
-
'terminated', // Undici (Node.js)
|
|
412
|
-
]);
|
|
413
|
-
function isHttpConnectionError(error) {
|
|
414
|
-
if (error instanceof TypeError) {
|
|
415
|
-
if (error.message === 'Load failed') {
|
|
416
|
-
return error.stack === undefined;
|
|
417
|
-
}
|
|
418
|
-
return errorMessages.has(error.message);
|
|
419
|
-
}
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
400
|
//# sourceMappingURL=client.js.map
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AA6eA,8CAYC;AAiBD,sDAUC;AAnhBD,2DAA0E;AAE1E,yDAAuD;AAsDvD,MAAa,UAAU;IAYnB,YAAY,UAA6B,EAAE;QAJnC,mBAAc,GAAG,CAAC,CAAA;QAKtB,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAA;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAChC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;QAChF,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC,CAAA;QAC/C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,KAAK,CAAA;QAC/C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;QACtC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QAClC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAA;IACvC,CAAC;IAED,GAAG,CAAU,GAAW,EAAE,OAAwB;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,CAA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,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;QAC/C,IAAI,UAAU,IAAI,IAAI;YAAE,OAAO,SAAS,CAAA;QACxC,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;YAAE,OAAO,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,IAAI,CAAA;QACpE,IAAI,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IACzG,CAAC;IAED,OAAO,SAAS,CAAA;AACpB,CAAC;AAED,MAAM,eAAe,GAAG,kIAAkI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../src/client.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const assert_1 = __importDefault(require("assert"));
|
|
7
|
+
const node_test_1 = require("node:test");
|
|
8
|
+
const client_1 = require("./client");
|
|
9
|
+
(0, node_test_1.it)('basic auth', async () => {
|
|
10
|
+
let client = new client_1.HttpClient();
|
|
11
|
+
let credentials = await client.get('http://hello:world@httpbin.org/basic-auth/hello/world');
|
|
12
|
+
assert_1.default.deepStrictEqual(credentials, { authenticated: true, user: 'hello' });
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=client.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.test.js","sourceRoot":"","sources":["../src/client.test.ts"],"names":[],"mappings":";;;;;AAAA,oDAA2B;AAC3B,yCAA4B;AAC5B,qCAAmC;AAGnC,IAAA,cAAE,EAAC,YAAY,EAAE,KAAK,IAAI,EAAE;IACxB,IAAI,MAAM,GAAG,IAAI,mBAAU,EAAE,CAAA;IAC7B,IAAI,WAAW,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAA;IAC3F,gBAAM,CAAC,eAAe,CAAC,WAAW,EAAE,EAAC,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAA;AAC7E,CAAC,CAAC,CAAA"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,OAAO,EAAC,aAAa,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.HttpAgent = void 0;
|
|
17
18
|
__exportStar(require("./client"), exports);
|
|
19
|
+
var agent_1 = require("./agent");
|
|
20
|
+
Object.defineProperty(exports, "HttpAgent", { enumerable: true, get: function () { return agent_1.HttpAgent; } });
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,iCAAgD;AAAzB,kGAAA,SAAS,OAAA"}
|
package/lib/request.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RequestInit, Response } from 'node-fetch';
|
|
2
|
+
export declare const nodeFetch: {
|
|
3
|
+
load(): Promise<typeof import("node-fetch")>;
|
|
4
|
+
readonly Headers: typeof import("node-fetch").Headers;
|
|
5
|
+
readonly FetchError: typeof import("node-fetch").FetchError;
|
|
6
|
+
readonly isLoaded: boolean;
|
|
7
|
+
request(url: string, init?: RequestInit): Promise<Response>;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAA;AAOrD,eAAO,MAAM,SAAS;YACJ,OAAO,CAAC,cAAc,YAAY,CAAC,CAAC;;;;iBAe/B,MAAM,SAAS,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;CAIpE,CAAA"}
|
package/lib/request.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.nodeFetch = void 0;
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
8
|
+
const esm_1 = require("../esm");
|
|
9
|
+
let mod;
|
|
10
|
+
exports.nodeFetch = {
|
|
11
|
+
async load() {
|
|
12
|
+
if (mod)
|
|
13
|
+
return mod;
|
|
14
|
+
return mod = await (0, esm_1.esm)('node-fetch');
|
|
15
|
+
},
|
|
16
|
+
get Headers() {
|
|
17
|
+
(0, assert_1.default)(mod, 'node-fetch ESM is not loaded');
|
|
18
|
+
return mod.Headers;
|
|
19
|
+
},
|
|
20
|
+
get FetchError() {
|
|
21
|
+
(0, assert_1.default)(mod, 'node-fetch ESM is not loaded');
|
|
22
|
+
return mod.FetchError;
|
|
23
|
+
},
|
|
24
|
+
get isLoaded() {
|
|
25
|
+
return !!mod;
|
|
26
|
+
},
|
|
27
|
+
async request(url, init) {
|
|
28
|
+
let m = await exports.nodeFetch.load();
|
|
29
|
+
return m.default(url, init);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAE3B,gCAA0B;AAG1B,IAAI,GAA4C,CAAA;AAGnC,QAAA,SAAS,GAAG;IACrB,KAAK,CAAC,IAAI;QACN,IAAI,GAAG;YAAE,OAAO,GAAG,CAAA;QACnB,OAAO,GAAG,GAAG,MAAM,IAAA,SAAG,EAA+B,YAAY,CAAC,CAAA;IACtE,CAAC;IACD,IAAI,OAAO;QACP,IAAA,gBAAM,EAAC,GAAG,EAAE,8BAA8B,CAAC,CAAA;QAC3C,OAAO,GAAG,CAAC,OAAO,CAAA;IACtB,CAAC;IACD,IAAI,UAAU;QACV,IAAA,gBAAM,EAAC,GAAG,EAAE,8BAA8B,CAAC,CAAA;QAC3C,OAAO,GAAG,CAAC,UAAU,CAAA;IACzB,CAAC;IACD,IAAI,QAAQ;QACR,OAAO,CAAC,CAAC,GAAG,CAAA;IAChB,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,IAAkB;QACzC,IAAI,CAAC,GAAG,MAAM,iBAAS,CAAC,IAAI,EAAE,CAAA;QAC9B,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC/B,CAAC;CACJ,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subsquid/http-client",
|
|
3
|
-
"version": "1.7.0-
|
|
3
|
+
"version": "1.7.0-portal-api.d887ad",
|
|
4
4
|
"description": "Small convenience layer on top of fetch",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"repository": "git@github.com:subsquid/squid.git",
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
"esm.js"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@subsquid/logger": "
|
|
19
|
-
"@subsquid/util-internal": "3.3.0-
|
|
20
|
-
"
|
|
18
|
+
"@subsquid/logger": "1.5.0-portal-api.d887ad",
|
|
19
|
+
"@subsquid/util-internal": "3.3.0-portal-api.d887ad",
|
|
20
|
+
"node-fetch": "^3.3.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"
|
|
23
|
+
"@types/node": "^18.18.14",
|
|
24
|
+
"typescript": "5.5.4"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"build": "rm -rf lib && tsc"
|
package/src/agent.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as http from 'http'
|
|
2
|
+
import * as https from 'https'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export interface AgentProvider {
|
|
6
|
+
getNativeAgent(url: string): http.Agent
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export const defaultAgentProvider: AgentProvider = {
|
|
11
|
+
getNativeAgent(url: string): http.Agent {
|
|
12
|
+
if (url.startsWith('https://')) {
|
|
13
|
+
return https.globalAgent
|
|
14
|
+
} else {
|
|
15
|
+
return http.globalAgent
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export class HttpAgent implements AgentProvider {
|
|
22
|
+
private http?: http.Agent
|
|
23
|
+
private https?: https.Agent
|
|
24
|
+
|
|
25
|
+
constructor(private options: https.AgentOptions) {}
|
|
26
|
+
|
|
27
|
+
getNativeAgent(url: string): http.Agent {
|
|
28
|
+
if (url.startsWith('https://')) {
|
|
29
|
+
return this.https || (this.https = new https.Agent(this.options))
|
|
30
|
+
} else {
|
|
31
|
+
return this.http || (this.http = new http.Agent(this.options))
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
close() {
|
|
36
|
+
this.http?.destroy()
|
|
37
|
+
this.https?.destroy()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import {it} from 'node:test'
|
|
3
|
+
import {HttpClient} from './client'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
it('basic auth', async () => {
|
|
7
|
+
let client = new HttpClient()
|
|
8
|
+
let credentials = await client.get('http://hello:world@httpbin.org/basic-auth/hello/world')
|
|
9
|
+
assert.deepStrictEqual(credentials, {authenticated: true, user: 'hello'})
|
|
10
|
+
})
|
package/src/client.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type {Logger} from '@subsquid/logger'
|
|
2
|
+
import {createLogger} from '@subsquid/logger'
|
|
2
3
|
import {addErrorContext, ensureError, wait} from '@subsquid/util-internal'
|
|
4
|
+
import type {Headers, RequestInit, Response} from 'node-fetch'
|
|
5
|
+
import {AgentProvider, defaultAgentProvider} from './agent'
|
|
3
6
|
import {HttpBody} from './body'
|
|
4
|
-
import {
|
|
7
|
+
import {nodeFetch} from './request'
|
|
8
|
+
import {Readable} from 'stream'
|
|
9
|
+
|
|
5
10
|
|
|
6
11
|
export {HttpBody}
|
|
7
12
|
|
|
13
|
+
|
|
8
14
|
export interface HttpClientOptions {
|
|
15
|
+
agent?: AgentProvider
|
|
9
16
|
baseUrl?: string
|
|
10
17
|
headers?: Record<string, string | number | bigint>
|
|
11
18
|
/**
|
|
@@ -15,27 +22,23 @@ export interface HttpClientOptions {
|
|
|
15
22
|
* Overall request processing time might be much larger due to retries.
|
|
16
23
|
*/
|
|
17
24
|
httpTimeout?: number
|
|
18
|
-
bodyTimeout?: number
|
|
19
25
|
retryAttempts?: number
|
|
20
26
|
retrySchedule?: number[]
|
|
21
|
-
keepalive?: boolean
|
|
22
|
-
|
|
23
27
|
log?: Logger | null
|
|
24
|
-
fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>
|
|
25
28
|
}
|
|
26
29
|
|
|
30
|
+
|
|
27
31
|
export interface RequestOptions {
|
|
28
32
|
query?: Record<string, string | number | bigint>
|
|
29
33
|
headers?: HeadersInit
|
|
30
34
|
retryAttempts?: number
|
|
31
35
|
retrySchedule?: number[]
|
|
32
36
|
httpTimeout?: number
|
|
33
|
-
bodyTimeout?: number
|
|
34
37
|
abort?: AbortSignal
|
|
35
38
|
stream?: boolean
|
|
36
|
-
keepalive?: boolean
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
|
|
39
42
|
export interface GraphqlRequestOptions extends RequestOptions {
|
|
40
43
|
variables?: Record<string, any>
|
|
41
44
|
url?: string
|
|
@@ -43,54 +46,52 @@ export interface GraphqlRequestOptions extends RequestOptions {
|
|
|
43
46
|
stream?: false
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
|
|
46
50
|
export interface FetchRequest extends RequestInit {
|
|
47
51
|
id: number
|
|
48
52
|
url: string
|
|
49
53
|
headers: Headers
|
|
50
54
|
timeout?: number
|
|
51
|
-
bodyTimeout?: number
|
|
52
55
|
signal?: AbortSignal
|
|
53
56
|
stream?: boolean
|
|
54
57
|
}
|
|
55
58
|
|
|
59
|
+
|
|
56
60
|
export type FetchResponse = Response
|
|
57
61
|
|
|
62
|
+
|
|
58
63
|
export class HttpClient {
|
|
59
64
|
protected log?: Logger
|
|
60
65
|
protected headers?: Record<string, string | number | bigint>
|
|
61
66
|
private baseUrl?: string
|
|
67
|
+
private agent: AgentProvider
|
|
62
68
|
private retrySchedule: number[]
|
|
63
69
|
private retryAttempts: number
|
|
64
70
|
private httpTimeout: number
|
|
65
|
-
private bodyTimeout?: number
|
|
66
71
|
private requestCounter = 0
|
|
67
|
-
private keepalive?: boolean
|
|
68
|
-
private fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>
|
|
69
72
|
|
|
70
73
|
constructor(options: HttpClientOptions = {}) {
|
|
71
|
-
this.log = options.log === null ? undefined : options.log
|
|
74
|
+
this.log = options.log === null ? undefined : options.log || createLogger('sqd:http-client')
|
|
72
75
|
this.headers = options.headers
|
|
73
76
|
this.setBaseUrl(options.baseUrl)
|
|
77
|
+
this.agent = options.agent || defaultAgentProvider
|
|
74
78
|
this.retrySchedule = options.retrySchedule || [10, 100, 500, 2000, 10000, 20000]
|
|
75
79
|
this.retryAttempts = options.retryAttempts || 0
|
|
76
80
|
this.httpTimeout = options.httpTimeout ?? 20000
|
|
77
|
-
this.bodyTimeout = options.bodyTimeout
|
|
78
|
-
this.keepalive = options.keepalive
|
|
79
|
-
this.fetch = options.fetch || fetch
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
get<T
|
|
83
|
-
return this.request('GET', url, options).then(
|
|
83
|
+
get<T=any>(url: string, options?: RequestOptions): Promise<T> {
|
|
84
|
+
return this.request('GET', url, options).then(res => res.body)
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
post<T
|
|
87
|
-
return this.request('POST', url, options).then(
|
|
87
|
+
post<T=any>(url: string, options?: RequestOptions & HttpBody): Promise<T> {
|
|
88
|
+
return this.request('POST', url, options).then(res => res.body)
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
async request<T
|
|
91
|
+
async request<T=any>(
|
|
91
92
|
method: string,
|
|
92
93
|
url: string,
|
|
93
|
-
options: RequestOptions & HttpBody = {}
|
|
94
|
+
options: RequestOptions & HttpBody = {},
|
|
94
95
|
): Promise<HttpResponse<T>> {
|
|
95
96
|
let req = await this.prepareRequest(method, url, options)
|
|
96
97
|
|
|
@@ -106,7 +107,9 @@ export class HttpClient {
|
|
|
106
107
|
if (retryAttempts > retries && this.isRetryableError(res, req)) {
|
|
107
108
|
let pause = asRetryAfterPause(res)
|
|
108
109
|
if (pause == null) {
|
|
109
|
-
pause = retrySchedule.length
|
|
110
|
+
pause = retrySchedule.length
|
|
111
|
+
? retrySchedule[Math.min(retries, retrySchedule.length - 1)]
|
|
112
|
+
: 1000
|
|
110
113
|
}
|
|
111
114
|
retries += 1
|
|
112
115
|
this.beforeRetryPause(req, res, pause)
|
|
@@ -124,16 +127,13 @@ export class HttpClient {
|
|
|
124
127
|
|
|
125
128
|
protected beforeRequest(req: FetchRequest): void {
|
|
126
129
|
if (this.log?.isDebug()) {
|
|
127
|
-
this.log.debug(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
'http request'
|
|
136
|
-
)
|
|
130
|
+
this.log.debug({
|
|
131
|
+
httpRequestId: req.id,
|
|
132
|
+
httpRequestUrl: req.url,
|
|
133
|
+
httpRequestMethod: req.method,
|
|
134
|
+
httpRequestHeaders: Array.from(req.headers),
|
|
135
|
+
httpRequestBody: req.body
|
|
136
|
+
}, 'http request')
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -142,8 +142,7 @@ export class HttpClient {
|
|
|
142
142
|
let info: any = {
|
|
143
143
|
httpRequestId: req.id,
|
|
144
144
|
httpRequestUrl: req.url,
|
|
145
|
-
httpRequestMethod: req.method
|
|
146
|
-
httpRequestBody: req.body,
|
|
145
|
+
httpRequestMethod: req.method
|
|
147
146
|
}
|
|
148
147
|
if (reason instanceof Error) {
|
|
149
148
|
info.reason = reason.toString()
|
|
@@ -160,15 +159,12 @@ export class HttpClient {
|
|
|
160
159
|
|
|
161
160
|
protected afterResponseHeaders(req: FetchRequest, url: string, status: number, headers: Headers): void {
|
|
162
161
|
if (this.log?.isDebug()) {
|
|
163
|
-
this.log.debug(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
},
|
|
170
|
-
'http headers'
|
|
171
|
-
)
|
|
162
|
+
this.log.debug({
|
|
163
|
+
httpRequestId: req.id,
|
|
164
|
+
httpResponseUrl: url,
|
|
165
|
+
httpResponseStatus: status,
|
|
166
|
+
httpResponseHeaders: Array.from(headers)
|
|
167
|
+
}, 'http headers')
|
|
172
168
|
}
|
|
173
169
|
}
|
|
174
170
|
|
|
@@ -180,13 +176,10 @@ export class HttpClient {
|
|
|
180
176
|
httpResponseBody = '...body is too long to be logged'
|
|
181
177
|
}
|
|
182
178
|
}
|
|
183
|
-
this.log.debug(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
},
|
|
188
|
-
'http body'
|
|
189
|
-
)
|
|
179
|
+
this.log.debug({
|
|
180
|
+
httpRequestId: req.id,
|
|
181
|
+
httpResponseBody
|
|
182
|
+
}, 'http body')
|
|
190
183
|
}
|
|
191
184
|
}
|
|
192
185
|
|
|
@@ -195,16 +188,17 @@ export class HttpClient {
|
|
|
195
188
|
url: string,
|
|
196
189
|
options: RequestOptions & HttpBody
|
|
197
190
|
): Promise<FetchRequest> {
|
|
191
|
+
await nodeFetch.load()
|
|
192
|
+
|
|
198
193
|
let req: FetchRequest = {
|
|
199
194
|
id: this.requestCounter++,
|
|
200
195
|
method,
|
|
201
|
-
headers: new Headers(options.headers),
|
|
196
|
+
headers: new nodeFetch.Headers(options.headers),
|
|
202
197
|
url: this.getAbsUrl(url),
|
|
203
198
|
signal: options.abort,
|
|
199
|
+
compress: true,
|
|
204
200
|
timeout: options.httpTimeout ?? this.httpTimeout,
|
|
205
|
-
|
|
206
|
-
stream: options.stream,
|
|
207
|
-
keepalive: options.keepalive ?? this.keepalive,
|
|
201
|
+
stream: options.stream
|
|
208
202
|
}
|
|
209
203
|
|
|
210
204
|
this.handleBasicAuth(req)
|
|
@@ -218,14 +212,18 @@ export class HttpClient {
|
|
|
218
212
|
}
|
|
219
213
|
}
|
|
220
214
|
|
|
215
|
+
req.agent = this.agent.getNativeAgent(req.url)
|
|
216
|
+
|
|
221
217
|
if (options.content !== undefined) {
|
|
222
218
|
if (typeof options.content == 'string') {
|
|
223
219
|
req.body = options.content
|
|
224
220
|
if (!req.headers.has('content-type')) {
|
|
225
221
|
req.headers.set('content-type', 'text/plain')
|
|
226
222
|
}
|
|
227
|
-
} else {
|
|
223
|
+
} else if (Buffer.isBuffer(options.content)) {
|
|
228
224
|
req.body = options.content
|
|
225
|
+
} else {
|
|
226
|
+
req.body = Buffer.from(options.content.buffer, options.content.byteOffset, options.content.byteLength)
|
|
229
227
|
}
|
|
230
228
|
}
|
|
231
229
|
|
|
@@ -238,7 +236,7 @@ export class HttpClient {
|
|
|
238
236
|
|
|
239
237
|
for (let name in this.headers) {
|
|
240
238
|
if (!req.headers.has(name)) {
|
|
241
|
-
req.headers.set(name, ''
|
|
239
|
+
req.headers.set(name, ''+this.headers[name])
|
|
242
240
|
}
|
|
243
241
|
}
|
|
244
242
|
|
|
@@ -273,31 +271,31 @@ export class HttpClient {
|
|
|
273
271
|
|
|
274
272
|
let res: HttpResponse | undefined
|
|
275
273
|
try {
|
|
276
|
-
return
|
|
277
|
-
} catch
|
|
274
|
+
return res = await this.performRequest({...req, signal: ac.signal})
|
|
275
|
+
} catch(err: any) {
|
|
278
276
|
if (timer == null) {
|
|
279
277
|
throw new HttpTimeoutError(req.timeout)
|
|
280
278
|
} else {
|
|
281
279
|
throw err
|
|
282
280
|
}
|
|
283
281
|
} finally {
|
|
284
|
-
|
|
282
|
+
if (timer != null) {
|
|
283
|
+
clearTimeout(timer)
|
|
284
|
+
}
|
|
285
285
|
req.signal?.removeEventListener('abort', abort)
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
private async performRequest(req: FetchRequest): Promise<HttpResponse> {
|
|
290
|
-
let res = await
|
|
290
|
+
let res = await nodeFetch.request(req.url, req)
|
|
291
291
|
this.afterResponseHeaders(req, res.url, res.status, res.headers)
|
|
292
|
-
let
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
res.headers,
|
|
298
|
-
|
|
299
|
-
body instanceof ReadableStream
|
|
300
|
-
)
|
|
292
|
+
let httpResponse
|
|
293
|
+
if (req.stream && res.ok) {
|
|
294
|
+
httpResponse = new HttpResponse(req.id, res.url, res.status, res.headers, res.body, res.body != null)
|
|
295
|
+
} else {
|
|
296
|
+
let body = await this.handleResponseBody(req, res)
|
|
297
|
+
httpResponse = new HttpResponse(req.id, res.url, res.status, res.headers, body, false)
|
|
298
|
+
}
|
|
301
299
|
this.afterResponse(req, httpResponse)
|
|
302
300
|
return httpResponse
|
|
303
301
|
}
|
|
@@ -305,15 +303,6 @@ export class HttpClient {
|
|
|
305
303
|
protected async handleResponseBody(req: FetchRequest, res: FetchResponse): Promise<any> {
|
|
306
304
|
let contentType = (res.headers.get('content-type') || '').split(';')[0]
|
|
307
305
|
|
|
308
|
-
if (req.bodyTimeout != null && res.body != null) {
|
|
309
|
-
let body = addStreamTimeout(res.body, req.bodyTimeout, () => new HttpBodyTimeoutError(req.bodyTimeout!))
|
|
310
|
-
res = new Response(body, res)
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (req.stream && res.ok && res.body != null) {
|
|
314
|
-
return res.body
|
|
315
|
-
}
|
|
316
|
-
|
|
317
306
|
if (contentType == 'application/json') {
|
|
318
307
|
return res.json()
|
|
319
308
|
}
|
|
@@ -324,7 +313,7 @@ export class HttpClient {
|
|
|
324
313
|
|
|
325
314
|
let arrayBuffer = await res.arrayBuffer()
|
|
326
315
|
if (arrayBuffer.byteLength == 0) return undefined
|
|
327
|
-
return arrayBuffer
|
|
316
|
+
return Buffer.from(arrayBuffer)
|
|
328
317
|
}
|
|
329
318
|
|
|
330
319
|
isRetryableError(error: HttpResponse | Error, req?: FetchRequest): boolean {
|
|
@@ -334,7 +323,7 @@ export class HttpClient {
|
|
|
334
323
|
error = error.response
|
|
335
324
|
}
|
|
336
325
|
if (error instanceof HttpResponse) {
|
|
337
|
-
switch
|
|
326
|
+
switch(error.status) {
|
|
338
327
|
case 429:
|
|
339
328
|
case 502:
|
|
340
329
|
case 503:
|
|
@@ -348,7 +337,7 @@ export class HttpClient {
|
|
|
348
337
|
return false
|
|
349
338
|
}
|
|
350
339
|
|
|
351
|
-
private getRequestUrlAndAuth(url: string): {url: string
|
|
340
|
+
private getRequestUrlAndAuth(url: string): {url: string, basic?: string} {
|
|
352
341
|
let u = new URL(this.getAbsUrl(url))
|
|
353
342
|
if (u.username || u.password) {
|
|
354
343
|
let basic = btoa(u.username + ':' + u.password)
|
|
@@ -383,7 +372,7 @@ export class HttpClient {
|
|
|
383
372
|
}
|
|
384
373
|
}
|
|
385
374
|
|
|
386
|
-
async graphqlRequest<T
|
|
375
|
+
async graphqlRequest<T=any>(gql: string, options: GraphqlRequestOptions = {}): Promise<T> {
|
|
387
376
|
let {method = 'POST', url = '/', variables, ...reqOptions} = options
|
|
388
377
|
let req: RequestOptions & {json?: any} = reqOptions
|
|
389
378
|
if (method == 'GET') {
|
|
@@ -397,10 +386,10 @@ export class HttpClient {
|
|
|
397
386
|
} else {
|
|
398
387
|
req.json = {
|
|
399
388
|
query: gql,
|
|
400
|
-
variables
|
|
389
|
+
variables
|
|
401
390
|
}
|
|
402
391
|
}
|
|
403
|
-
let res = await this.request<{data: T
|
|
392
|
+
let res = await this.request<{data: T, errors?: GraphqlMessage[]}>(method, url, req)
|
|
404
393
|
if (res.body.errors?.length) {
|
|
405
394
|
throw new GraphqlError(res.body.errors)
|
|
406
395
|
} else {
|
|
@@ -409,7 +398,8 @@ export class HttpClient {
|
|
|
409
398
|
}
|
|
410
399
|
}
|
|
411
400
|
|
|
412
|
-
|
|
401
|
+
|
|
402
|
+
export class HttpResponse<T=any> {
|
|
413
403
|
constructor(
|
|
414
404
|
public readonly requestId: number,
|
|
415
405
|
public readonly url: string,
|
|
@@ -417,7 +407,8 @@ export class HttpResponse<T = any> {
|
|
|
417
407
|
public readonly headers: Headers,
|
|
418
408
|
public readonly body: T,
|
|
419
409
|
public readonly stream: boolean
|
|
420
|
-
) {
|
|
410
|
+
) {
|
|
411
|
+
}
|
|
421
412
|
|
|
422
413
|
get ok(): boolean {
|
|
423
414
|
return this.status >= 200 && this.status < 300
|
|
@@ -433,11 +424,12 @@ export class HttpResponse<T = any> {
|
|
|
433
424
|
status: this.status,
|
|
434
425
|
headers: Array.from(this.headers),
|
|
435
426
|
body: this.stream ? undefined : this.body,
|
|
436
|
-
url: this.url
|
|
427
|
+
url: this.url
|
|
437
428
|
}
|
|
438
429
|
}
|
|
439
430
|
}
|
|
440
431
|
|
|
432
|
+
|
|
441
433
|
export class HttpError extends Error {
|
|
442
434
|
constructor(public readonly response: HttpResponse) {
|
|
443
435
|
super(`Got ${response.status} from ${response.url}`)
|
|
@@ -448,6 +440,7 @@ export class HttpError extends Error {
|
|
|
448
440
|
}
|
|
449
441
|
}
|
|
450
442
|
|
|
443
|
+
|
|
451
444
|
export class HttpTimeoutError extends Error {
|
|
452
445
|
constructor(public readonly ms: number) {
|
|
453
446
|
super(`request timed out after ${ms} ms`)
|
|
@@ -458,21 +451,13 @@ export class HttpTimeoutError extends Error {
|
|
|
458
451
|
}
|
|
459
452
|
}
|
|
460
453
|
|
|
461
|
-
export class HttpBodyTimeoutError extends Error {
|
|
462
|
-
constructor(ms: number) {
|
|
463
|
-
super(`request body timed out after ${ms} ms`)
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
get name(): string {
|
|
467
|
-
return 'HttpBodyTimeoutError'
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
454
|
|
|
471
455
|
export interface GraphqlMessage {
|
|
472
456
|
message: string
|
|
473
457
|
path?: (string | number)[]
|
|
474
458
|
}
|
|
475
459
|
|
|
460
|
+
|
|
476
461
|
export class GraphqlError extends Error {
|
|
477
462
|
constructor(public readonly messages: GraphqlMessage[]) {
|
|
478
463
|
super(`GraphQL error: ${messages[0].message}`)
|
|
@@ -483,13 +468,18 @@ export class GraphqlError extends Error {
|
|
|
483
468
|
}
|
|
484
469
|
}
|
|
485
470
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
471
|
+
|
|
472
|
+
export function isHttpConnectionError(err: unknown): boolean {
|
|
473
|
+
return nodeFetch.isLoaded
|
|
474
|
+
&& err instanceof nodeFetch.FetchError
|
|
475
|
+
&& err.type == 'system'
|
|
476
|
+
&& (
|
|
477
|
+
err.message.startsWith('request to') ||
|
|
478
|
+
err.code == 'ERR_STREAM_PREMATURE_CLOSE' ||
|
|
479
|
+
err.code == 'ECONNRESET'
|
|
480
|
+
)
|
|
481
|
+
}
|
|
482
|
+
|
|
493
483
|
|
|
494
484
|
export function asRetryAfterPause(res: HttpResponse | Error): number | undefined {
|
|
495
485
|
if (res instanceof HttpError) {
|
|
@@ -505,29 +495,4 @@ export function asRetryAfterPause(res: HttpResponse | Error): number | undefined
|
|
|
505
495
|
return undefined
|
|
506
496
|
}
|
|
507
497
|
|
|
508
|
-
const HTTP_DATE_REGEX =
|
|
509
|
-
/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/
|
|
510
|
-
|
|
511
|
-
// ref: https://github.com/sindresorhus/is-network-error/blob/main/index.js
|
|
512
|
-
const errorMessages = new Set([
|
|
513
|
-
'network error', // Chrome
|
|
514
|
-
'Failed to fetch', // Chrome
|
|
515
|
-
'NetworkError when attempting to fetch resource.', // Firefox
|
|
516
|
-
'The Internet connection appears to be offline.', // Safari 16
|
|
517
|
-
'Load failed', // Safari 17+
|
|
518
|
-
'Network request failed', // `cross-fetch`
|
|
519
|
-
'fetch failed', // Undici (Node.js)
|
|
520
|
-
'terminated', // Undici (Node.js)
|
|
521
|
-
])
|
|
522
|
-
|
|
523
|
-
export function isHttpConnectionError(error: unknown) {
|
|
524
|
-
if (error instanceof TypeError) {
|
|
525
|
-
if (error.message === 'Load failed') {
|
|
526
|
-
return error.stack === undefined
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
return errorMessages.has(error.message)
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
return false
|
|
533
|
-
}
|
|
498
|
+
const HTTP_DATE_REGEX = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/;
|
package/src/index.ts
CHANGED
package/src/request.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import type {RequestInit, Response} from 'node-fetch'
|
|
3
|
+
import {esm} from '../esm'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
let mod: typeof import('node-fetch') | undefined
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const nodeFetch = {
|
|
10
|
+
async load(): Promise<typeof import('node-fetch')> {
|
|
11
|
+
if (mod) return mod
|
|
12
|
+
return mod = await esm<typeof import('node-fetch') >('node-fetch')
|
|
13
|
+
},
|
|
14
|
+
get Headers() {
|
|
15
|
+
assert(mod, 'node-fetch ESM is not loaded')
|
|
16
|
+
return mod.Headers
|
|
17
|
+
},
|
|
18
|
+
get FetchError() {
|
|
19
|
+
assert(mod, 'node-fetch ESM is not loaded')
|
|
20
|
+
return mod.FetchError
|
|
21
|
+
},
|
|
22
|
+
get isLoaded() {
|
|
23
|
+
return !!mod
|
|
24
|
+
},
|
|
25
|
+
async request(url: string, init?: RequestInit): Promise<Response> {
|
|
26
|
+
let m = await nodeFetch.load()
|
|
27
|
+
return m.default(url, init)
|
|
28
|
+
}
|
|
29
|
+
}
|