@clickhouse/client 1.18.1 → 1.18.2-head.9835b07.1
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/README.md +67 -2
- package/dist/config.d.ts +3 -2
- package/dist/config.js.map +1 -1
- package/dist/connection/node_base_connection.d.ts +4 -26
- package/dist/connection/node_base_connection.js +8 -454
- package/dist/connection/node_base_connection.js.map +1 -1
- package/dist/connection/node_custom_agent_connection.d.ts +2 -1
- package/dist/connection/node_custom_agent_connection.js.map +1 -1
- package/dist/connection/node_http_connection.d.ts +2 -1
- package/dist/connection/node_http_connection.js.map +1 -1
- package/dist/connection/node_https_connection.d.ts +2 -1
- package/dist/connection/node_https_connection.js.map +1 -1
- package/dist/connection/socket_pool.d.ts +42 -0
- package/dist/connection/socket_pool.js +546 -0
- package/dist/connection/socket_pool.js.map +1 -0
- package/dist/utils/stream.js +14 -13
- package/dist/utils/stream.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node_https_connection.js","sourceRoot":"","sources":["../../src/connection/node_https_connection.ts"],"names":[],"mappings":";;;;;;AAAA,6DAIkC;AAElC,kDAAyB;
|
|
1
|
+
{"version":3,"file":"node_https_connection.js","sourceRoot":"","sources":["../../src/connection/node_https_connection.ts"],"names":[],"mappings":";;;;;;AAAA,6DAIkC;AAElC,kDAAyB;AAGzB,iEAA2D;AAE3D,MAAa,mBAAoB,SAAQ,yCAAkB;IACzD,YAAY,MAA4B;QACtC,MAAM,KAAK,GAAG,IAAI,eAAK,CAAC,KAAK,CAAC;YAC5B,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO;YACpC,UAAU,EAAE,MAAM,CAAC,oBAAoB;YACvC,EAAE,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO;YACvB,GAAG,EAAE,MAAM,CAAC,GAAG,EAA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K,QAAQ;oBACX,OAAO;wBACL,GAAG,OAAO;wBACV,mCAAmC,EAAE,IAAI;qBAC1C,CAAA;gBACH;oBACE,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAA;YACnD,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAC1C,CAAC;IAES,mBAAmB,CAAC,MAAqB;QACjD,MAAM,OAAO,GAAG,IAAA,sCAAsB,EAAC;YACrC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,0BAA0B,EAAE,MAAM,CAAC,0BAA0B;YAC7D,2BAA2B,EAAE,MAAM,CAAC,2BAA2B;SAChE,CAAC,CAAA;QACF,OAAO,eAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE;YAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe;YACpC,MAAM,EAAE,MAAM,CAAC,YAAY;YAC3B,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AAjED,kDAiEC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type Http from 'http';
|
|
2
|
+
import Stream from 'stream';
|
|
3
|
+
import { ClickHouseLogLevel, type LogWriter, type ConnOperation, type ResponseHeaders, type ClickHouseSummary } from '@clickhouse/client-common';
|
|
4
|
+
import { type NodeConnectionParams } from './node_base_connection';
|
|
5
|
+
export interface RequestParams {
|
|
6
|
+
method: 'GET' | 'POST';
|
|
7
|
+
url: URL;
|
|
8
|
+
headers: Http.OutgoingHttpHeaders;
|
|
9
|
+
body?: string | Stream.Readable;
|
|
10
|
+
abort_signal: AbortSignal;
|
|
11
|
+
enable_response_compression?: boolean;
|
|
12
|
+
enable_request_compression?: boolean;
|
|
13
|
+
try_decompress_response_stream?: boolean;
|
|
14
|
+
ignore_error_response?: boolean;
|
|
15
|
+
parse_summary?: boolean;
|
|
16
|
+
query: string;
|
|
17
|
+
query_id: string;
|
|
18
|
+
log_writer: LogWriter;
|
|
19
|
+
log_level: ClickHouseLogLevel;
|
|
20
|
+
}
|
|
21
|
+
export interface RequestResult {
|
|
22
|
+
stream: Stream.Readable;
|
|
23
|
+
response_headers: ResponseHeaders;
|
|
24
|
+
http_status_code?: number;
|
|
25
|
+
summary?: ClickHouseSummary;
|
|
26
|
+
}
|
|
27
|
+
type CreateClientRequest = (params: RequestParams) => Http.ClientRequest;
|
|
28
|
+
export declare class SocketPool {
|
|
29
|
+
private readonly connectionId;
|
|
30
|
+
private readonly params;
|
|
31
|
+
private readonly createClientRequest;
|
|
32
|
+
private readonly jsonHandling;
|
|
33
|
+
private readonly knownSockets;
|
|
34
|
+
private requestCounter;
|
|
35
|
+
private getNewRequestId;
|
|
36
|
+
private socketCounter;
|
|
37
|
+
private getNewSocketId;
|
|
38
|
+
constructor(connectionId: string, params: NodeConnectionParams, createClientRequest: CreateClientRequest);
|
|
39
|
+
request(params: RequestParams, op: ConnOperation): Promise<RequestResult>;
|
|
40
|
+
private parseSummary;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,546 @@
|
|
|
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.SocketPool = void 0;
|
|
7
|
+
const stream_1 = __importDefault(require("stream"));
|
|
8
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
9
|
+
const client_common_1 = require("@clickhouse/client-common");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const compression_1 = require("./compression");
|
|
12
|
+
class SocketPool {
|
|
13
|
+
connectionId;
|
|
14
|
+
params;
|
|
15
|
+
createClientRequest;
|
|
16
|
+
jsonHandling;
|
|
17
|
+
knownSockets = new WeakMap();
|
|
18
|
+
// For overflow concerns:
|
|
19
|
+
// node -e 'console.log(Number.MAX_SAFE_INTEGER / (1_000_000 * 60 * 60 * 24 * 366))'
|
|
20
|
+
// gives 284 years of continuous operation at 1M requests per second
|
|
21
|
+
// before overflowing the 53-bit integer
|
|
22
|
+
requestCounter = 0;
|
|
23
|
+
getNewRequestId() {
|
|
24
|
+
this.requestCounter += 1;
|
|
25
|
+
return `${this.connectionId}:${this.requestCounter}`;
|
|
26
|
+
}
|
|
27
|
+
socketCounter = 0;
|
|
28
|
+
getNewSocketId() {
|
|
29
|
+
this.socketCounter += 1;
|
|
30
|
+
return `${this.connectionId}:${this.socketCounter}`;
|
|
31
|
+
}
|
|
32
|
+
constructor(connectionId, params, createClientRequest) {
|
|
33
|
+
this.connectionId = connectionId;
|
|
34
|
+
this.params = params;
|
|
35
|
+
this.createClientRequest = createClientRequest;
|
|
36
|
+
this.jsonHandling = params.json ?? {
|
|
37
|
+
parse: JSON.parse,
|
|
38
|
+
stringify: JSON.stringify,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async request(params, op) {
|
|
42
|
+
// allows the event loop to process the idle socket timers, if the CPU load is high
|
|
43
|
+
// otherwise, we can occasionally get an expired socket, see https://github.com/ClickHouse/clickhouse-js/issues/294
|
|
44
|
+
await (0, client_common_1.sleep)(0);
|
|
45
|
+
const { log_writer, query_id, log_level } = params;
|
|
46
|
+
const currentStackTrace = this.params.capture_enhanced_stack_trace
|
|
47
|
+
? (0, client_common_1.getCurrentStackTrace)()
|
|
48
|
+
: undefined;
|
|
49
|
+
const requestTimeout = this.params.request_timeout;
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
const start = Date.now();
|
|
52
|
+
const request = this.createClientRequest(params);
|
|
53
|
+
const request_id = this.getNewRequestId();
|
|
54
|
+
const onError = (e) => {
|
|
55
|
+
removeRequestListeners();
|
|
56
|
+
if (e instanceof Error) {
|
|
57
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.TRACE) {
|
|
58
|
+
if (e.code === 'ECONNRESET') {
|
|
59
|
+
log_writer.trace({
|
|
60
|
+
message: `${op}: connection reset by peer`,
|
|
61
|
+
args: {
|
|
62
|
+
operation: op,
|
|
63
|
+
connection_id: this.connectionId,
|
|
64
|
+
query_id,
|
|
65
|
+
request_id,
|
|
66
|
+
},
|
|
67
|
+
module: 'HTTP Adapter',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.WARN) {
|
|
72
|
+
if (this.params.keep_alive.enabled) {
|
|
73
|
+
if (e.code === 'ECONNRESET') {
|
|
74
|
+
const socket = request.socket;
|
|
75
|
+
if (socket) {
|
|
76
|
+
const socketInfo = this.knownSockets.get(socket);
|
|
77
|
+
if (socketInfo) {
|
|
78
|
+
const serverTimeoutMs = socketInfo.server_keep_alive_timeout_ms;
|
|
79
|
+
if (serverTimeoutMs !== undefined) {
|
|
80
|
+
if (this.params.keep_alive.idle_socket_ttl > serverTimeoutMs) {
|
|
81
|
+
log_writer.warn({
|
|
82
|
+
message: `${op}: idle socket TTL is greater than server keep-alive timeout, try setting idle socket TTL to a value lower than the server keep-alive timeout to prevent unexpected connection resets, see https://c.house/js_keep_alive_econnreset for more details.`,
|
|
83
|
+
args: {
|
|
84
|
+
operation: op,
|
|
85
|
+
connection_id: this.connectionId,
|
|
86
|
+
query_id,
|
|
87
|
+
request_id,
|
|
88
|
+
socket_id: socketInfo.id,
|
|
89
|
+
server_keep_alive_timeout_ms: serverTimeoutMs,
|
|
90
|
+
idle_socket_ttl: this.params.keep_alive.idle_socket_ttl,
|
|
91
|
+
},
|
|
92
|
+
module: 'HTTP Adapter',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const err = (0, client_common_1.enhanceStackTrace)(e, currentStackTrace);
|
|
102
|
+
reject(err);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
reject(e);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
let responseStream;
|
|
109
|
+
const onResponse = async (_response) => {
|
|
110
|
+
if (this.params.log_level <= client_common_1.ClickHouseLogLevel.DEBUG) {
|
|
111
|
+
const duration = Date.now() - start;
|
|
112
|
+
this.params.log_writer.debug({
|
|
113
|
+
module: 'HTTP Adapter',
|
|
114
|
+
message: `${op}: got a response from ClickHouse`,
|
|
115
|
+
args: {
|
|
116
|
+
operation: op,
|
|
117
|
+
connection_id: this.connectionId,
|
|
118
|
+
query_id,
|
|
119
|
+
request_id,
|
|
120
|
+
request_method: params.method,
|
|
121
|
+
request_path: params.url.pathname,
|
|
122
|
+
response_status: _response.statusCode,
|
|
123
|
+
response_time_ms: duration,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (this.params.keep_alive.enabled) {
|
|
128
|
+
const keepAliveHeader = _response.headers['keep-alive'];
|
|
129
|
+
if (keepAliveHeader) {
|
|
130
|
+
const [, timeout] = /timeout=(\d+)/i.exec(String(keepAliveHeader)) ?? [];
|
|
131
|
+
if (timeout) {
|
|
132
|
+
const socketInfo = this.knownSockets.get(_response.socket);
|
|
133
|
+
if (socketInfo) {
|
|
134
|
+
const timeoutMs = Number(timeout) * 1000;
|
|
135
|
+
socketInfo.server_keep_alive_timeout_ms = timeoutMs;
|
|
136
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.TRACE) {
|
|
137
|
+
this.params.log_writer.trace({
|
|
138
|
+
module: 'HTTP Adapter',
|
|
139
|
+
message: `${op}: updated server sent socket keep-alive timeout`,
|
|
140
|
+
args: {
|
|
141
|
+
operation: op,
|
|
142
|
+
connection_id: this.connectionId,
|
|
143
|
+
query_id,
|
|
144
|
+
request_id,
|
|
145
|
+
socket_id: socketInfo.id,
|
|
146
|
+
server_keep_alive_timeout_ms: timeoutMs,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const tryDecompressResponseStream = params.try_decompress_response_stream ?? true;
|
|
155
|
+
const ignoreErrorResponse = params.ignore_error_response ?? false;
|
|
156
|
+
// even if the stream decompression is disabled, we have to decompress it in case of an error
|
|
157
|
+
const isFailedResponse = !(0, client_common_1.isSuccessfulResponse)(_response.statusCode);
|
|
158
|
+
if (tryDecompressResponseStream ||
|
|
159
|
+
(isFailedResponse && !ignoreErrorResponse)) {
|
|
160
|
+
const decompressionResult = (0, compression_1.decompressResponse)(_response, log_writer, log_level);
|
|
161
|
+
if ((0, compression_1.isDecompressionError)(decompressionResult)) {
|
|
162
|
+
const err = (0, client_common_1.enhanceStackTrace)(decompressionResult.error, currentStackTrace);
|
|
163
|
+
return reject(err);
|
|
164
|
+
}
|
|
165
|
+
responseStream = decompressionResult.response;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
responseStream = _response;
|
|
169
|
+
}
|
|
170
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.TRACE) {
|
|
171
|
+
log_writer.trace({
|
|
172
|
+
message: `${op}: response stream created`,
|
|
173
|
+
args: {
|
|
174
|
+
operation: op,
|
|
175
|
+
connection_id: this.connectionId,
|
|
176
|
+
query_id,
|
|
177
|
+
request_id,
|
|
178
|
+
stream_state: {
|
|
179
|
+
readable: responseStream.readable,
|
|
180
|
+
readableEnded: responseStream.readableEnded,
|
|
181
|
+
readableLength: responseStream.readableLength,
|
|
182
|
+
},
|
|
183
|
+
is_failed_response: isFailedResponse,
|
|
184
|
+
will_decompress: tryDecompressResponseStream,
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (isFailedResponse && !ignoreErrorResponse) {
|
|
189
|
+
try {
|
|
190
|
+
const errorMessage = await (0, utils_1.getAsText)(responseStream);
|
|
191
|
+
const err = (0, client_common_1.enhanceStackTrace)((0, client_common_1.parseError)(errorMessage), currentStackTrace);
|
|
192
|
+
reject(err);
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
// If the ClickHouse response is malformed
|
|
196
|
+
const err = (0, client_common_1.enhanceStackTrace)(e, currentStackTrace);
|
|
197
|
+
reject(err);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return resolve({
|
|
202
|
+
stream: responseStream,
|
|
203
|
+
summary: params.parse_summary
|
|
204
|
+
? this.parseSummary(op, _response)
|
|
205
|
+
: undefined,
|
|
206
|
+
response_headers: { ..._response.headers },
|
|
207
|
+
http_status_code: _response.statusCode ?? undefined,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
function onAbort() {
|
|
212
|
+
// Prefer 'abort' event since it always triggered unlike 'error' and 'close'
|
|
213
|
+
// see the full sequence of events https://nodejs.org/api/http.html#httprequesturl-options-callback
|
|
214
|
+
removeRequestListeners();
|
|
215
|
+
request.once('error', function () {
|
|
216
|
+
/**
|
|
217
|
+
* catch "Error: ECONNRESET" error which shouldn't be reported to users.
|
|
218
|
+
* see the full sequence of events https://nodejs.org/api/http.html#httprequesturl-options-callback
|
|
219
|
+
* */
|
|
220
|
+
});
|
|
221
|
+
const err = (0, client_common_1.enhanceStackTrace)(new Error('The user aborted a request.'), currentStackTrace);
|
|
222
|
+
reject(err);
|
|
223
|
+
}
|
|
224
|
+
function onClose() {
|
|
225
|
+
// Adapter uses 'close' event to clean up listeners after the successful response.
|
|
226
|
+
// It's necessary in order to handle 'abort' and 'timeout' events while response is streamed.
|
|
227
|
+
// It's always the last event, according to https://nodejs.org/docs/latest-v14.x/api/http.html#http_http_request_url_options_callback
|
|
228
|
+
removeRequestListeners();
|
|
229
|
+
}
|
|
230
|
+
function pipeStream() {
|
|
231
|
+
// if request.end() was called due to no data to send
|
|
232
|
+
if (request.writableEnded) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const bodyStream = (0, utils_1.isStream)(params.body)
|
|
236
|
+
? params.body
|
|
237
|
+
: stream_1.default.Readable.from([params.body]);
|
|
238
|
+
const callback = (e) => {
|
|
239
|
+
if (e) {
|
|
240
|
+
removeRequestListeners();
|
|
241
|
+
const err = (0, client_common_1.enhanceStackTrace)(e, currentStackTrace);
|
|
242
|
+
reject(err);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
if (params.enable_request_compression) {
|
|
246
|
+
stream_1.default.pipeline(bodyStream, zlib_1.default.createGzip(), request, callback);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
stream_1.default.pipeline(bodyStream, request, callback);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const onSocket = (socket) => {
|
|
253
|
+
try {
|
|
254
|
+
if (this.params.keep_alive.enabled &&
|
|
255
|
+
this.params.keep_alive.idle_socket_ttl > 0) {
|
|
256
|
+
const socketInfo = this.knownSockets.get(socket);
|
|
257
|
+
// It is the first time we've encountered this socket,
|
|
258
|
+
// so it doesn't have the idle timeout handler attached to it
|
|
259
|
+
if (socketInfo === undefined) {
|
|
260
|
+
const socket_id = this.getNewSocketId();
|
|
261
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.TRACE) {
|
|
262
|
+
log_writer.trace({
|
|
263
|
+
message: `${op}: using a fresh socket, setting up a new 'free' listener`,
|
|
264
|
+
args: {
|
|
265
|
+
operation: op,
|
|
266
|
+
connection_id: this.connectionId,
|
|
267
|
+
query_id,
|
|
268
|
+
request_id,
|
|
269
|
+
socket_id,
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
const newSocketInfo = {
|
|
274
|
+
id: socket_id,
|
|
275
|
+
idle_timeout_handle: undefined,
|
|
276
|
+
usage_count: 1,
|
|
277
|
+
};
|
|
278
|
+
this.knownSockets.set(socket, newSocketInfo);
|
|
279
|
+
// When the request is complete and the socket is released,
|
|
280
|
+
// make sure that the socket is removed after `idle_socket_ttl`.
|
|
281
|
+
socket.on('free', () => {
|
|
282
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.TRACE) {
|
|
283
|
+
log_writer.trace({
|
|
284
|
+
message: `${op}: socket was released`,
|
|
285
|
+
args: {
|
|
286
|
+
operation: op,
|
|
287
|
+
connection_id: this.connectionId,
|
|
288
|
+
query_id,
|
|
289
|
+
request_id,
|
|
290
|
+
socket_id,
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
// Avoiding the built-in socket.timeout() method usage here,
|
|
295
|
+
// as we don't want to clash with the actual request timeout.
|
|
296
|
+
const idleTimeoutHandle = setTimeout(() => {
|
|
297
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.TRACE) {
|
|
298
|
+
log_writer.trace({
|
|
299
|
+
message: `${op}: removing idle socket`,
|
|
300
|
+
args: {
|
|
301
|
+
operation: op,
|
|
302
|
+
connection_id: this.connectionId,
|
|
303
|
+
query_id,
|
|
304
|
+
request_id,
|
|
305
|
+
socket_id,
|
|
306
|
+
idle_socket_ttl_ms: this.params.keep_alive.idle_socket_ttl,
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
this.knownSockets.delete(socket);
|
|
311
|
+
socket.destroy();
|
|
312
|
+
}, this.params.keep_alive.idle_socket_ttl).unref();
|
|
313
|
+
newSocketInfo.idle_timeout_handle = idleTimeoutHandle;
|
|
314
|
+
});
|
|
315
|
+
const cleanup = (eventName) => () => {
|
|
316
|
+
const maybeSocketInfo = this.knownSockets.get(socket);
|
|
317
|
+
// clean up a possibly dangling idle timeout handle (preventing leaks)
|
|
318
|
+
if (maybeSocketInfo?.idle_timeout_handle) {
|
|
319
|
+
clearTimeout(maybeSocketInfo.idle_timeout_handle);
|
|
320
|
+
}
|
|
321
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.TRACE) {
|
|
322
|
+
log_writer.trace({
|
|
323
|
+
message: `${op}: received '${eventName}' event, 'free' listener removed`,
|
|
324
|
+
args: {
|
|
325
|
+
operation: op,
|
|
326
|
+
connection_id: this.connectionId,
|
|
327
|
+
query_id,
|
|
328
|
+
request_id,
|
|
329
|
+
socket_id,
|
|
330
|
+
event: eventName,
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.WARN) {
|
|
335
|
+
if (responseStream && !responseStream.readableEnded) {
|
|
336
|
+
log_writer.warn({
|
|
337
|
+
message: `${op}: socket was closed or ended before the response was fully read. ` +
|
|
338
|
+
'This can potentially result in an uncaught ECONNRESET error! ' +
|
|
339
|
+
'Consider fully consuming, draining, or destroying the response stream.',
|
|
340
|
+
args: {
|
|
341
|
+
operation: op,
|
|
342
|
+
connection_id: this.connectionId,
|
|
343
|
+
query_id,
|
|
344
|
+
request_id,
|
|
345
|
+
socket_id,
|
|
346
|
+
event: eventName,
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
socket.once('end', cleanup('end'));
|
|
353
|
+
socket.once('close', cleanup('close'));
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
clearTimeout(socketInfo.idle_timeout_handle);
|
|
357
|
+
socketInfo.idle_timeout_handle = undefined;
|
|
358
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.TRACE) {
|
|
359
|
+
log_writer.trace({
|
|
360
|
+
message: `${op}: reusing socket`,
|
|
361
|
+
args: {
|
|
362
|
+
operation: op,
|
|
363
|
+
connection_id: this.connectionId,
|
|
364
|
+
query_id,
|
|
365
|
+
request_id,
|
|
366
|
+
socket_id: socketInfo.id,
|
|
367
|
+
usage_count: socketInfo.usage_count,
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
socketInfo.usage_count++;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
catch (e) {
|
|
376
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.ERROR) {
|
|
377
|
+
log_writer.error({
|
|
378
|
+
message: `${op}: an error occurred while housekeeping the idle sockets`,
|
|
379
|
+
err: e,
|
|
380
|
+
args: {
|
|
381
|
+
operation: op,
|
|
382
|
+
connection_id: this.connectionId,
|
|
383
|
+
query_id,
|
|
384
|
+
request_id,
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
// Socket is "prepared" with idle handlers, continue with our request
|
|
390
|
+
pipeStream();
|
|
391
|
+
// This is for request timeout only. Surprisingly, it is not always enough to set in the HTTP request.
|
|
392
|
+
// The socket won't be destroyed, and it will be returned to the pool.
|
|
393
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.TRACE) {
|
|
394
|
+
const socketInfo = this.knownSockets.get(socket);
|
|
395
|
+
if (socketInfo) {
|
|
396
|
+
log_writer.trace({
|
|
397
|
+
message: `${op}: setting up request timeout`,
|
|
398
|
+
args: {
|
|
399
|
+
operation: op,
|
|
400
|
+
connection_id: this.connectionId,
|
|
401
|
+
query_id,
|
|
402
|
+
request_id,
|
|
403
|
+
socket_id: socketInfo.id,
|
|
404
|
+
timeout_ms: requestTimeout,
|
|
405
|
+
},
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
log_writer.trace({
|
|
410
|
+
message: `${op}: setting up request timeout on a socket`,
|
|
411
|
+
args: {
|
|
412
|
+
operation: op,
|
|
413
|
+
connection_id: this.connectionId,
|
|
414
|
+
query_id,
|
|
415
|
+
request_id,
|
|
416
|
+
timeout_ms: requestTimeout,
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
socket.setTimeout(this.params.request_timeout, onTimeout);
|
|
422
|
+
};
|
|
423
|
+
const onTimeout = () => {
|
|
424
|
+
removeRequestListeners();
|
|
425
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.TRACE) {
|
|
426
|
+
const socket = request.socket;
|
|
427
|
+
const maybeSocketInfo = socket
|
|
428
|
+
? this.knownSockets.get(socket)
|
|
429
|
+
: undefined;
|
|
430
|
+
const socketState = request.socket
|
|
431
|
+
? {
|
|
432
|
+
connecting: request.socket.connecting,
|
|
433
|
+
pending: request.socket.pending,
|
|
434
|
+
destroyed: request.socket.destroyed,
|
|
435
|
+
readyState: request.socket.readyState,
|
|
436
|
+
}
|
|
437
|
+
: undefined;
|
|
438
|
+
const responseStreamState = responseStream
|
|
439
|
+
? {
|
|
440
|
+
readable: responseStream.readable,
|
|
441
|
+
readableEnded: responseStream.readableEnded,
|
|
442
|
+
readableLength: responseStream.readableLength,
|
|
443
|
+
}
|
|
444
|
+
: undefined;
|
|
445
|
+
log_writer.trace({
|
|
446
|
+
message: `${op}: timeout occurred`,
|
|
447
|
+
args: {
|
|
448
|
+
operation: op,
|
|
449
|
+
connection_id: this.connectionId,
|
|
450
|
+
query_id,
|
|
451
|
+
request_id,
|
|
452
|
+
socket_id: maybeSocketInfo?.id,
|
|
453
|
+
timeout_ms: requestTimeout,
|
|
454
|
+
socket_state: socketState,
|
|
455
|
+
response_stream_state: responseStreamState,
|
|
456
|
+
has_response_stream: responseStream !== undefined,
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
const err = (0, client_common_1.enhanceStackTrace)(new Error('Timeout error.'), currentStackTrace);
|
|
461
|
+
try {
|
|
462
|
+
request.destroy();
|
|
463
|
+
}
|
|
464
|
+
catch (e) {
|
|
465
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.ERROR) {
|
|
466
|
+
log_writer.error({
|
|
467
|
+
message: `${op}: An error occurred while destroying the request`,
|
|
468
|
+
err: e,
|
|
469
|
+
args: {
|
|
470
|
+
operation: op,
|
|
471
|
+
connection_id: this.connectionId,
|
|
472
|
+
query_id,
|
|
473
|
+
request_id,
|
|
474
|
+
},
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
reject(err);
|
|
479
|
+
};
|
|
480
|
+
function removeRequestListeners() {
|
|
481
|
+
if (request.socket) {
|
|
482
|
+
request.socket.setTimeout(0); // reset previously set timeout
|
|
483
|
+
request.socket.removeListener('timeout', onTimeout);
|
|
484
|
+
}
|
|
485
|
+
request.removeListener('socket', onSocket);
|
|
486
|
+
request.removeListener('response', onResponse);
|
|
487
|
+
request.removeListener('error', onError);
|
|
488
|
+
request.removeListener('close', onClose);
|
|
489
|
+
if (params.abort_signal) {
|
|
490
|
+
request.removeListener('abort', onAbort);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
request.on('socket', onSocket);
|
|
494
|
+
request.on('response', onResponse);
|
|
495
|
+
request.on('error', onError);
|
|
496
|
+
request.on('close', onClose);
|
|
497
|
+
if (params.abort_signal) {
|
|
498
|
+
params.abort_signal.addEventListener('abort', onAbort, {
|
|
499
|
+
once: true,
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
if (!params.body) {
|
|
503
|
+
try {
|
|
504
|
+
return request.end();
|
|
505
|
+
}
|
|
506
|
+
catch (e) {
|
|
507
|
+
if (log_level <= client_common_1.ClickHouseLogLevel.ERROR) {
|
|
508
|
+
log_writer.error({
|
|
509
|
+
message: `${op}: an error occurred while ending the request without body`,
|
|
510
|
+
err: e,
|
|
511
|
+
args: {
|
|
512
|
+
operation: op,
|
|
513
|
+
connection_id: this.connectionId,
|
|
514
|
+
query_id,
|
|
515
|
+
request_id,
|
|
516
|
+
},
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
parseSummary(op, response) {
|
|
524
|
+
const summaryHeader = response.headers['x-clickhouse-summary'];
|
|
525
|
+
if (typeof summaryHeader === 'string') {
|
|
526
|
+
try {
|
|
527
|
+
return this.jsonHandling.parse(summaryHeader);
|
|
528
|
+
}
|
|
529
|
+
catch (err) {
|
|
530
|
+
if (this.params.log_level <= client_common_1.ClickHouseLogLevel.ERROR) {
|
|
531
|
+
this.params.log_writer.error({
|
|
532
|
+
message: `${op}: failed to parse X-ClickHouse-Summary header.`,
|
|
533
|
+
args: {
|
|
534
|
+
operation: op,
|
|
535
|
+
connection_id: this.connectionId,
|
|
536
|
+
'X-ClickHouse-Summary': summaryHeader,
|
|
537
|
+
},
|
|
538
|
+
err: err,
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
exports.SocketPool = SocketPool;
|
|
546
|
+
//# sourceMappingURL=socket_pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket_pool.js","sourceRoot":"","sources":["../../src/connection/socket_pool.ts"],"names":[],"mappings":";;;;;;AACA,oDAA2B;AAE3B,gDAAuB;AACvB,6DAYkC;AAClC,oCAA8C;AAC9C,+CAAwE;AAuCxE,MAAa,UAAU;IAqBF;IACA;IACA;IAtBF,YAAY,CAAc;IAC1B,YAAY,GAAG,IAAI,OAAO,EAA0B,CAAA;IAErE,yBAAyB;IACzB,sFAAsF;IACtF,oEAAoE;IACpE,wCAAwC;IAChC,cAAc,GAAG,CAAC,CAAA;IAClB,eAAe;QACrB,IAAI,CAAC,cAAc,IAAI,CAAC,CAAA;QACxB,OAAO,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,cAAc,EAAE,CAAA;IACtD,CAAC;IAEO,aAAa,GAAG,CAAC,CAAA;IACjB,cAAc;QACpB,IAAI,CAAC,aAAa,IAAI,CAAC,CAAA;QACvB,OAAO,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,aAAa,EAAE,CAAA;IACrD,CAAC;IAED,YACmB,YAAoB,EACpB,MAA4B,EAC5B,mBAAwC;QAFxC,iBAAY,GAAZ,YAAY,CAAQ;QACpB,WAAM,GAAN,MAAM,CAAsB;QAC5B,wBAAmB,GAAnB,mBAAmB,CAAqB;QAEzD,IAAI,CAAC,YAAY,GAAG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