gremlin 3.7.1 → 3.7.2
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/.eslintrc.js +3 -4
- package/.nvmrc +1 -0
- package/LICENSE +9 -1
- package/NOTICE +1 -1
- package/README.md +1 -1
- package/doc/AnonymousTraversalSource.html +2 -2
- package/doc/Authenticator.html +2 -2
- package/doc/Bytecode.html +2 -2
- package/doc/CardinalityValue.html +2 -2
- package/doc/Client.html +9 -108
- package/doc/Connection.html +9 -196
- package/doc/DataType.js.html +149 -0
- package/doc/DriverRemoteConnection.html +12 -111
- package/doc/EdgeLabelVerificationStrategy.html +2 -2
- package/doc/Graph.html +2 -2
- package/doc/GraphBinaryReader.js.html +132 -0
- package/doc/GraphBinaryWriter.js.html +135 -0
- package/doc/GraphSON2Reader.html +4 -4
- package/doc/GraphSON2Writer.html +5 -5
- package/doc/GraphSON3Reader.html +3 -3
- package/doc/GraphSON3Writer.html +3 -3
- package/doc/GraphTraversal.html +2 -2
- package/doc/GraphTraversalSource.html +2 -2
- package/doc/HaltedTraverserStrategy.html +2 -2
- package/doc/MatchAlgorithmStrategy.html +2 -2
- package/doc/P.html +2 -2
- package/doc/PartitionStrategy.html +2 -2
- package/doc/Path.html +2 -2
- package/doc/PlainTextSaslAuthenticator.html +2 -2
- package/doc/ProductiveByStrategy.html +2 -2
- package/doc/RemoteConnection.html +2 -2
- package/doc/RemoteStrategy.html +2 -2
- package/doc/RemoteTraversal.html +2 -2
- package/doc/ReservedKeysVerificationStrategy.html +2 -2
- package/doc/ResponseError.html +2 -2
- package/doc/ResultSet.html +7 -95
- package/doc/SaslAuthenticator.html +2 -2
- package/doc/SaslMechanismBase.html +2 -2
- package/doc/SaslMechanismPlain.html +7 -7
- package/doc/SeedStrategy.html +2 -2
- package/doc/SubgraphStrategy.html +2 -2
- package/doc/TextP.html +2 -2
- package/doc/Transaction.html +5 -5
- package/doc/Translator.html +2 -2
- package/doc/TraversalStrategies.html +2 -2
- package/doc/TraversalStrategy.html +2 -2
- package/doc/TypeSerializer.html +2 -2
- package/doc/driver_auth_authenticator.js.html +2 -2
- package/doc/driver_auth_mechanisms_sasl-mechanism-base.js.html +2 -2
- package/doc/driver_auth_mechanisms_sasl-mechanism-plain.js.html +3 -2
- package/doc/driver_auth_plain-text-sasl-authenticator.js.html +2 -2
- package/doc/driver_auth_sasl-authenticator.js.html +2 -2
- package/doc/driver_client.js.html +2 -5
- package/doc/driver_connection.js.html +82 -118
- package/doc/driver_driver-remote-connection.js.html +2 -5
- package/doc/driver_remote-connection.js.html +2 -2
- package/doc/driver_response-error.js.html +2 -2
- package/doc/driver_result-set.js.html +2 -11
- package/doc/global.html +158 -3
- package/doc/index.html +3 -3
- package/doc/module.exports.html +4 -4
- package/doc/process_anonymous-traversal.js.html +2 -2
- package/doc/process_bytecode.js.html +2 -2
- package/doc/process_graph-traversal.js.html +2 -2
- package/doc/process_transaction.js.html +12 -4
- package/doc/process_translator.js.html +2 -2
- package/doc/process_traversal-strategy.js.html +2 -2
- package/doc/process_traversal.js.html +2 -2
- package/doc/structure_graph.js.html +2 -2
- package/doc/structure_io_binary_internals_DataType.js.html +2 -2
- package/doc/structure_io_binary_internals_GraphBinaryReader.js.html +4 -2
- package/doc/structure_io_binary_internals_GraphBinaryWriter.js.html +4 -2
- package/doc/structure_io_graph-serializer.js.html +3 -2
- package/doc/structure_io_type-serializers.js.html +2 -2
- package/doc/utils.js.html +181 -0
- package/lib/driver/auth/mechanisms/sasl-mechanism-plain.js +1 -0
- package/lib/driver/client.js +0 -3
- package/lib/driver/connection.js +80 -116
- package/lib/driver/driver-remote-connection.js +0 -3
- package/lib/driver/result-set.js +0 -9
- package/lib/process/transaction.js +10 -2
- package/lib/structure/io/binary/internals/AnySerializer.js +2 -0
- package/lib/structure/io/binary/internals/ArraySerializer.js +2 -0
- package/lib/structure/io/binary/internals/BigIntegerSerializer.js +2 -0
- package/lib/structure/io/binary/internals/BooleanSerializer.js +2 -0
- package/lib/structure/io/binary/internals/BulkSetSerializer.js +2 -0
- package/lib/structure/io/binary/internals/ByteBufferSerializer.js +2 -0
- package/lib/structure/io/binary/internals/ByteSerializer.js +2 -0
- package/lib/structure/io/binary/internals/BytecodeSerializer.js +1 -0
- package/lib/structure/io/binary/internals/DateSerializer.js +2 -0
- package/lib/structure/io/binary/internals/DoubleSerializer.js +2 -0
- package/lib/structure/io/binary/internals/EdgeSerializer.js +1 -0
- package/lib/structure/io/binary/internals/EnumSerializer.js +1 -0
- package/lib/structure/io/binary/internals/FloatSerializer.js +2 -0
- package/lib/structure/io/binary/internals/GraphBinaryReader.js +2 -0
- package/lib/structure/io/binary/internals/GraphBinaryWriter.js +2 -0
- package/lib/structure/io/binary/internals/IntSerializer.js +2 -0
- package/lib/structure/io/binary/internals/LambdaSerializer.js +1 -0
- package/lib/structure/io/binary/internals/LongSerializer.js +2 -0
- package/lib/structure/io/binary/internals/LongSerializerNg.js +2 -0
- package/lib/structure/io/binary/internals/MapSerializer.js +2 -0
- package/lib/structure/io/binary/internals/PSerializer.js +1 -0
- package/lib/structure/io/binary/internals/PathSerializer.js +1 -0
- package/lib/structure/io/binary/internals/PropertySerializer.js +1 -0
- package/lib/structure/io/binary/internals/ShortSerializer.js +2 -0
- package/lib/structure/io/binary/internals/StringSerializer.js +2 -0
- package/lib/structure/io/binary/internals/TextPSerializer.js +1 -0
- package/lib/structure/io/binary/internals/TraversalStrategySerializer.js +2 -0
- package/lib/structure/io/binary/internals/TraverserSerializer.js +1 -0
- package/lib/structure/io/binary/internals/UnspecifiedNullSerializer.js +2 -0
- package/lib/structure/io/binary/internals/UuidSerializer.js +2 -0
- package/lib/structure/io/binary/internals/VertexPropertySerializer.js +1 -0
- package/lib/structure/io/binary/internals/VertexSerializer.js +1 -0
- package/lib/structure/io/binary/internals/utils.js +2 -0
- package/lib/structure/io/graph-serializer.js +1 -0
- package/lib/utils.js +40 -29
- package/licenses/chai +21 -0
- package/package.json +7 -3
package/lib/driver/connection.js
CHANGED
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
*/
|
|
23
23
|
'use strict';
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const util = require('util');
|
|
25
|
+
const { Buffer } = require('buffer');
|
|
26
|
+
const EventEmitter = require('eventemitter3');
|
|
27
|
+
const Stream = require('readable-stream');
|
|
29
28
|
const utils = require('../utils');
|
|
29
|
+
const { DeferredPromise } = utils;
|
|
30
30
|
const serializer = require('../structure/io/graph-serializer');
|
|
31
31
|
const { graphBinaryReader, graphBinaryWriter } = require('../structure/io/binary/GraphBinary');
|
|
32
32
|
const ResultSet = require('./result-set');
|
|
@@ -43,9 +43,6 @@ const defaultMimeType = 'application/vnd.gremlin-v3.0+json';
|
|
|
43
43
|
const graphSON2MimeType = 'application/vnd.gremlin-v2.0+json';
|
|
44
44
|
const graphBinaryMimeType = 'application/vnd.graphbinary-v1.0';
|
|
45
45
|
|
|
46
|
-
const pingIntervalDelay = 60 * 1000;
|
|
47
|
-
const pongTimeoutDelay = 30 * 1000;
|
|
48
|
-
|
|
49
46
|
const uuidPattern = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
|
|
50
47
|
|
|
51
48
|
/**
|
|
@@ -67,9 +64,6 @@ class Connection extends EventEmitter {
|
|
|
67
64
|
* @param {Authenticator} [options.authenticator] The authentication handler to use.
|
|
68
65
|
* @param {Object} [options.headers] An associative array containing the additional header key/values for the initial request.
|
|
69
66
|
* @param {Boolean} [options.enableUserAgentOnConnect] Determines if a user agent will be sent during connection handshake. Defaults to: true
|
|
70
|
-
* @param {Boolean} [options.pingEnabled] Setup ping interval. Defaults to: true.
|
|
71
|
-
* @param {Number} [options.pingInterval] Ping request interval in ms if ping enabled. Defaults to: 60000.
|
|
72
|
-
* @param {Number} [options.pongTimeout] Timeout of pong response in ms after sending a ping. Defaults to: 30000.
|
|
73
67
|
* @param {http.Agent} [options.agent] The http.Agent implementation to use.
|
|
74
68
|
* @constructor
|
|
75
69
|
*/
|
|
@@ -87,14 +81,12 @@ class Connection extends EventEmitter {
|
|
|
87
81
|
|
|
88
82
|
// A map containing the request id and the handler. The id should be in lower case to prevent string comparison issues.
|
|
89
83
|
this._responseHandlers = {};
|
|
90
|
-
this._reader = options.reader || this
|
|
91
|
-
this._writer = options.writer || this
|
|
84
|
+
this._reader = options.reader || this.#getDefaultReader(this.mimeType);
|
|
85
|
+
this._writer = options.writer || this.#getDefaultWriter(this.mimeType);
|
|
92
86
|
this._openPromise = null;
|
|
93
87
|
this._openCallback = null;
|
|
94
88
|
this._closePromise = null;
|
|
95
89
|
this._closeCallback = null;
|
|
96
|
-
this._pingInterval = null;
|
|
97
|
-
this._pongTimeout = null;
|
|
98
90
|
|
|
99
91
|
this._header = String.fromCharCode(this.mimeType.length) + this.mimeType; // TODO: what if mimeType.length > 255
|
|
100
92
|
this._header_buf = Buffer.from(this._header);
|
|
@@ -102,70 +94,61 @@ class Connection extends EventEmitter {
|
|
|
102
94
|
this.traversalSource = options.traversalSource || 'g';
|
|
103
95
|
this._authenticator = options.authenticator;
|
|
104
96
|
this._enableUserAgentOnConnect = options.enableUserAgentOnConnect !== false;
|
|
105
|
-
|
|
106
|
-
this._pingEnabled = this.options.pingEnabled === false ? false : true;
|
|
107
|
-
this._pingIntervalDelay = this.options.pingInterval || pingIntervalDelay;
|
|
108
|
-
this._pongTimeoutDelay = this.options.pongTimeout || pongTimeoutDelay;
|
|
109
97
|
}
|
|
110
98
|
|
|
111
99
|
/**
|
|
112
100
|
* Opens the connection, if its not already opened.
|
|
113
101
|
* @returns {Promise}
|
|
114
102
|
*/
|
|
115
|
-
open() {
|
|
103
|
+
async open() {
|
|
116
104
|
if (this.isOpen) {
|
|
117
|
-
return
|
|
105
|
+
return;
|
|
118
106
|
}
|
|
119
107
|
if (this._openPromise) {
|
|
120
108
|
return this._openPromise;
|
|
121
109
|
}
|
|
122
110
|
|
|
111
|
+
this._openPromise = DeferredPromise();
|
|
112
|
+
|
|
123
113
|
this.emit('log', 'ws open');
|
|
124
114
|
let headers = this.options.headers;
|
|
125
115
|
if (this._enableUserAgentOnConnect) {
|
|
126
116
|
if (!headers) {
|
|
127
117
|
headers = [];
|
|
128
118
|
}
|
|
129
|
-
|
|
119
|
+
|
|
120
|
+
const userAgent = await utils.getUserAgent();
|
|
121
|
+
if (userAgent !== undefined) {
|
|
122
|
+
headers[utils.getUserAgentHeader()] = await utils.getUserAgent();
|
|
123
|
+
}
|
|
130
124
|
}
|
|
131
125
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
126
|
+
const WebSocket = globalThis.WebSocket ?? (await import('ws')).default;
|
|
127
|
+
|
|
128
|
+
this._ws = new WebSocket(
|
|
129
|
+
this.url,
|
|
130
|
+
globalThis.WebSocket === undefined
|
|
131
|
+
? {
|
|
132
|
+
headers: headers,
|
|
133
|
+
ca: this.options.ca,
|
|
134
|
+
cert: this.options.cert,
|
|
135
|
+
pfx: this.options.pfx,
|
|
136
|
+
rejectUnauthorized: this.options.rejectUnauthorized,
|
|
137
|
+
agent: this.options.agent,
|
|
138
|
+
}
|
|
139
|
+
: undefined,
|
|
140
|
+
);
|
|
140
141
|
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
if ('binaryType' in this._ws) {
|
|
143
|
+
this._ws.binaryType = 'arraybuffer';
|
|
144
|
+
}
|
|
143
145
|
|
|
144
|
-
this._ws.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this._pongTimeout = null;
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
this._ws.on('ping', () => {
|
|
152
|
-
this.emit('log', 'ws ping received');
|
|
153
|
-
this._ws.pong();
|
|
154
|
-
});
|
|
146
|
+
this._ws.addEventListener('open', this.#handleOpen);
|
|
147
|
+
this._ws.addEventListener('error', this.#handleError);
|
|
148
|
+
this._ws.addEventListener('message', this.#handleMessage);
|
|
149
|
+
this._ws.addEventListener('close', this.#handleClose);
|
|
155
150
|
|
|
156
|
-
return
|
|
157
|
-
this._ws.on('open', () => {
|
|
158
|
-
this.isOpen = true;
|
|
159
|
-
if (this._pingEnabled) {
|
|
160
|
-
this._pingHeartbeat();
|
|
161
|
-
}
|
|
162
|
-
resolve();
|
|
163
|
-
});
|
|
164
|
-
this._ws.on('error', (err) => {
|
|
165
|
-
this._handleError(err);
|
|
166
|
-
reject(err);
|
|
167
|
-
});
|
|
168
|
-
}));
|
|
151
|
+
return await this._openPromise;
|
|
169
152
|
}
|
|
170
153
|
|
|
171
154
|
/** @override */
|
|
@@ -195,7 +178,7 @@ class Connection extends EventEmitter {
|
|
|
195
178
|
};
|
|
196
179
|
|
|
197
180
|
const request_buf = this._writer.writeRequest(request);
|
|
198
|
-
const message = Buffer.concat([this._header_buf, request_buf]);
|
|
181
|
+
const message = utils.toArrayBuffer(Buffer.concat([this._header_buf, request_buf]));
|
|
199
182
|
this._ws.send(message);
|
|
200
183
|
}),
|
|
201
184
|
);
|
|
@@ -230,7 +213,7 @@ class Connection extends EventEmitter {
|
|
|
230
213
|
};
|
|
231
214
|
|
|
232
215
|
const request_buf = this._writer.writeRequest(request);
|
|
233
|
-
const message = Buffer.concat([this._header_buf, request_buf]);
|
|
216
|
+
const message = utils.toArrayBuffer(Buffer.concat([this._header_buf, request_buf]));
|
|
234
217
|
this._ws.send(message);
|
|
235
218
|
})
|
|
236
219
|
.catch((err) => readableStream.destroy(err));
|
|
@@ -238,7 +221,7 @@ class Connection extends EventEmitter {
|
|
|
238
221
|
return readableStream;
|
|
239
222
|
}
|
|
240
223
|
|
|
241
|
-
|
|
224
|
+
#getDefaultReader(mimeType) {
|
|
242
225
|
if (mimeType === graphBinaryMimeType) {
|
|
243
226
|
return graphBinaryReader;
|
|
244
227
|
}
|
|
@@ -246,7 +229,7 @@ class Connection extends EventEmitter {
|
|
|
246
229
|
return mimeType === graphSON2MimeType ? new serializer.GraphSON2Reader() : new serializer.GraphSONReader();
|
|
247
230
|
}
|
|
248
231
|
|
|
249
|
-
|
|
232
|
+
#getDefaultWriter(mimeType) {
|
|
250
233
|
if (mimeType === graphBinaryMimeType) {
|
|
251
234
|
return graphBinaryWriter;
|
|
252
235
|
}
|
|
@@ -254,68 +237,58 @@ class Connection extends EventEmitter {
|
|
|
254
237
|
return mimeType === graphSON2MimeType ? new serializer.GraphSON2Writer() : new serializer.GraphSONWriter();
|
|
255
238
|
}
|
|
256
239
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
240
|
+
#handleOpen = () => {
|
|
241
|
+
this._openPromise.resolve();
|
|
242
|
+
this.isOpen = true;
|
|
243
|
+
};
|
|
262
244
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
this._pongTimeout = setTimeout(() => {
|
|
273
|
-
this._ws.terminate();
|
|
274
|
-
}, this._pongTimeoutDelay);
|
|
275
|
-
|
|
276
|
-
this._ws.ping();
|
|
277
|
-
}, this._pingIntervalDelay);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
_handleError(err) {
|
|
281
|
-
this.emit('log', `ws error ${err}`);
|
|
282
|
-
this._cleanupWebsocket(err);
|
|
283
|
-
this.emit('socketError', err);
|
|
284
|
-
}
|
|
245
|
+
/**
|
|
246
|
+
* @param {Event} event
|
|
247
|
+
*/
|
|
248
|
+
#handleError = ({ error }) => {
|
|
249
|
+
this._openPromise.reject(error);
|
|
250
|
+
this.emit('log', `ws error ${error}`);
|
|
251
|
+
this.#cleanupWebsocket(error);
|
|
252
|
+
this.emit('socketError', error);
|
|
253
|
+
};
|
|
285
254
|
|
|
286
|
-
|
|
255
|
+
/**
|
|
256
|
+
* @param {CloseEvent} event
|
|
257
|
+
*/
|
|
258
|
+
#handleClose = ({ code, message }) => {
|
|
287
259
|
this.emit('log', `ws close code=${code} message=${message}`);
|
|
288
|
-
this
|
|
260
|
+
this.#cleanupWebsocket();
|
|
289
261
|
if (this._closeCallback) {
|
|
290
262
|
this._closeCallback();
|
|
291
263
|
}
|
|
292
264
|
this.emit('close', code, message);
|
|
293
|
-
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @param {MessageEvent<any>} event
|
|
269
|
+
*/
|
|
270
|
+
#handleMessage = ({ data: _data }) => {
|
|
271
|
+
const data = _data instanceof ArrayBuffer ? Buffer.from(_data) : _data;
|
|
294
272
|
|
|
295
|
-
_handleMessage(data) {
|
|
296
273
|
const response = this._reader.readResponse(data);
|
|
297
274
|
if (response.requestId === null || response.requestId === undefined) {
|
|
298
275
|
// There was a serialization issue on the server that prevented the parsing of the request id
|
|
299
276
|
// We invoke any of the pending handlers with an error
|
|
300
277
|
Object.keys(this._responseHandlers).forEach((requestId) => {
|
|
301
278
|
const handler = this._responseHandlers[requestId];
|
|
302
|
-
this
|
|
279
|
+
this.#clearHandler(requestId);
|
|
303
280
|
if (response.status !== undefined && response.status.message) {
|
|
304
281
|
return handler.callback(
|
|
305
282
|
// TINKERPOP-2285: keep the old server error message in case folks are parsing that - fix in a future breaking version
|
|
306
283
|
new ResponseError(
|
|
307
|
-
|
|
308
|
-
'Server error (no request information): %s (%d)',
|
|
309
|
-
response.status.message,
|
|
310
|
-
response.status.code,
|
|
311
|
-
),
|
|
284
|
+
`Server error (no request information): ${response.status.message} (${response.status.code})`,
|
|
312
285
|
response.status,
|
|
313
286
|
),
|
|
314
287
|
);
|
|
315
288
|
}
|
|
316
289
|
// TINKERPOP-2285: keep the old server error message in case folks are parsing that - fix in a future breaking version
|
|
317
290
|
return handler.callback(
|
|
318
|
-
new ResponseError(
|
|
291
|
+
new ResponseError(`Server error (no request information): ${JSON.stringify(response)}`, response.status),
|
|
319
292
|
);
|
|
320
293
|
});
|
|
321
294
|
return;
|
|
@@ -342,10 +315,7 @@ class Connection extends EventEmitter {
|
|
|
342
315
|
// callback in error
|
|
343
316
|
return handler.callback(
|
|
344
317
|
// TINKERPOP-2285: keep the old server error message in case folks are parsing that - fix in a future breaking version
|
|
345
|
-
new ResponseError(
|
|
346
|
-
util.format('Server error: %s (%d)', response.status.message, response.status.code),
|
|
347
|
-
response.status,
|
|
348
|
-
),
|
|
318
|
+
new ResponseError(`Server error: ${response.status.message} (${response.status.code})`, response.status),
|
|
349
319
|
);
|
|
350
320
|
}
|
|
351
321
|
|
|
@@ -353,7 +323,7 @@ class Connection extends EventEmitter {
|
|
|
353
323
|
|
|
354
324
|
switch (response.status.code) {
|
|
355
325
|
case responseStatusCode.noContent:
|
|
356
|
-
this
|
|
326
|
+
this.#clearHandler(response.requestId);
|
|
357
327
|
if (isStreamingResponse) {
|
|
358
328
|
handler.result.push(new ResultSet(utils.emptyArray, response.status.attributes));
|
|
359
329
|
return handler.callback(null);
|
|
@@ -377,24 +347,15 @@ class Connection extends EventEmitter {
|
|
|
377
347
|
} else {
|
|
378
348
|
handler.result = response.result.data;
|
|
379
349
|
}
|
|
380
|
-
this
|
|
350
|
+
this.#clearHandler(response.requestId);
|
|
381
351
|
return handler.callback(null, new ResultSet(handler.result, response.status.attributes));
|
|
382
352
|
}
|
|
383
|
-
}
|
|
353
|
+
};
|
|
384
354
|
|
|
385
355
|
/**
|
|
386
356
|
* clean websocket context
|
|
387
357
|
*/
|
|
388
|
-
|
|
389
|
-
if (this._pingInterval) {
|
|
390
|
-
clearInterval(this._pingInterval);
|
|
391
|
-
}
|
|
392
|
-
this._pingInterval = null;
|
|
393
|
-
if (this._pongTimeout) {
|
|
394
|
-
clearTimeout(this._pongTimeout);
|
|
395
|
-
}
|
|
396
|
-
this._pongTimeout = null;
|
|
397
|
-
|
|
358
|
+
#cleanupWebsocket(err) {
|
|
398
359
|
// Invoke waiting callbacks to complete Promises when closing the websocket
|
|
399
360
|
Object.keys(this._responseHandlers).forEach((requestId) => {
|
|
400
361
|
const handler = this._responseHandlers[requestId];
|
|
@@ -406,7 +367,10 @@ class Connection extends EventEmitter {
|
|
|
406
367
|
handler.callback(cause);
|
|
407
368
|
}
|
|
408
369
|
});
|
|
409
|
-
this._ws.
|
|
370
|
+
this._ws.removeEventListener('open', this.#handleOpen);
|
|
371
|
+
this._ws.removeEventListener('error', this.#handleError);
|
|
372
|
+
this._ws.removeEventListener('message', this.#handleMessage);
|
|
373
|
+
this._ws.removeEventListener('close', this.#handleClose);
|
|
410
374
|
this._openPromise = null;
|
|
411
375
|
this._closePromise = null;
|
|
412
376
|
this.isOpen = false;
|
|
@@ -417,7 +381,7 @@ class Connection extends EventEmitter {
|
|
|
417
381
|
* @param requestId
|
|
418
382
|
* @private
|
|
419
383
|
*/
|
|
420
|
-
|
|
384
|
+
#clearHandler(requestId) {
|
|
421
385
|
delete this._responseHandlers[requestId];
|
|
422
386
|
}
|
|
423
387
|
|
|
@@ -49,9 +49,6 @@ class DriverRemoteConnection extends RemoteConnection {
|
|
|
49
49
|
* @param {Authenticator} [options.authenticator] The authentication handler to use.
|
|
50
50
|
* @param {Object} [options.headers] An associative array containing the additional header key/values for the initial request.
|
|
51
51
|
* @param {Boolean} [options.enableUserAgentOnConnect] Determines if a user agent will be sent during connection handshake. Defaults to: true
|
|
52
|
-
* @param {Boolean} [options.pingEnabled] Setup ping interval. Defaults to: true.
|
|
53
|
-
* @param {Number} [options.pingInterval] Ping request interval in ms if ping enabled. Defaults to: 60000.
|
|
54
|
-
* @param {Number} [options.pongTimeout] Timeout of pong response in ms after sending a ping. Defaults to: 30000.
|
|
55
52
|
* @param {http.Agent} [options.agent] The http.Agent implementation to use.
|
|
56
53
|
* @constructor
|
|
57
54
|
*/
|
package/lib/driver/result-set.js
CHANGED
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
*/
|
|
23
23
|
'use strict';
|
|
24
24
|
|
|
25
|
-
const util = require('util');
|
|
26
|
-
const inspect = util.inspect.custom || 'inspect';
|
|
27
25
|
const utils = require('../utils');
|
|
28
26
|
const emptyMap = Object.freeze(new utils.ImmutableMap());
|
|
29
27
|
|
|
@@ -64,13 +62,6 @@ class ResultSet {
|
|
|
64
62
|
return this._items[Symbol.iterator]();
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
/**
|
|
68
|
-
* Provides a representation useful for debug and tracing.
|
|
69
|
-
*/
|
|
70
|
-
[inspect]() {
|
|
71
|
-
return this._items;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
65
|
/**
|
|
75
66
|
* Gets an array of result items.
|
|
76
67
|
* @returns {Array}
|
|
@@ -59,14 +59,22 @@ class Transaction {
|
|
|
59
59
|
* @returns {Promise}
|
|
60
60
|
*/
|
|
61
61
|
commit() {
|
|
62
|
-
|
|
62
|
+
if (!this._sessionBasedConnection) {
|
|
63
|
+
throw new Error('Cannot commit a transaction that is not started');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return this._sessionBasedConnection.commit().finally(() => this.close());
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
/**
|
|
66
70
|
* @returns {Promise}
|
|
67
71
|
*/
|
|
68
72
|
rollback() {
|
|
69
|
-
|
|
73
|
+
if (!this._sessionBasedConnection) {
|
|
74
|
+
throw new Error('Cannot rollback a transaction that is not started');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return this._sessionBasedConnection.rollback().finally(() => this.close());
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
/**
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
'use strict';
|
|
24
24
|
|
|
25
|
+
const { Buffer } = require('buffer');
|
|
26
|
+
|
|
25
27
|
// TODO: it's based on BigInt native JavaScript type to completely support
|
|
26
28
|
// 64 bits integers, but for backward compatibility with current GraphSON
|
|
27
29
|
// implementation we do not use this for now. Consider its removal.
|