Skip to content

Commit 1ab1b8b

Browse files
committed
JS driver v1.3.0: Checking in transpiled files for bower
1 parent 0cef23d commit 1ab1b8b

File tree

13 files changed

+2055
-1329
lines changed

13 files changed

+2055
-1329
lines changed

lib/browser/neo4j-web.js

Lines changed: 884 additions & 581 deletions
Large diffs are not rendered by default.

lib/browser/neo4j-web.min.js

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/browser/neo4j-web.test.js

Lines changed: 1080 additions & 698 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/v1/driver.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
7171
var READ = 'READ',
7272
WRITE = 'WRITE';
7373
/**
74-
* A driver maintains one or more {@link Session sessions} with a remote
75-
* Neo4j instance. Through the {@link Session sessions} you can send statements
74+
* A driver maintains one or more {@link Session}s with a remote
75+
* Neo4j instance. Through the {@link Session}s you can send statements
7676
* and retrieve results from the database.
7777
*
7878
* Drivers are reasonably expensive to create - you should strive to keep one
@@ -161,7 +161,7 @@ var Driver = function () {
161161
* will be pulling a session out of the common pool.
162162
*
163163
* This comes with some responsibility - make sure you always call
164-
* {@link Session#close()} when you are done using a session, and likewise,
164+
* {@link close} when you are done using a session, and likewise,
165165
* make sure you don't close your session before you are done using it. Once
166166
* it is returned to the pool, the session will be reset to a clean state and
167167
* made available for others to use.

lib/v1/error.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
4545
// A common place for constructing error objects, to keep them
4646
// uniform across the driver surface.
4747

48+
/**
49+
* @type {string}
50+
*/
4851
var SERVICE_UNAVAILABLE = 'ServiceUnavailable';
52+
/**
53+
* @type {string}
54+
*/
4955
var SESSION_EXPIRED = 'SessionExpired';
56+
/**
57+
* @type {string}
58+
*/
5059
var PROTOCOL_ERROR = 'ProtocolError';
5160

5261
function newError(message) {

lib/v1/graph-types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var Node = function () {
4949
/**
5050
* @constructor
5151
* @param {Integer} identity - Unique identity
52-
* @param {Array} labels - Array for all labels
52+
* @param {Array<string>} labels - Array for all labels
5353
* @param {Object} properties - Map with node properties
5454
*/
5555
function Node(identity, labels, properties) {
@@ -211,7 +211,7 @@ var Path =
211211
* @constructor
212212
* @param {Node} start - start node
213213
* @param {Node} end - end node
214-
* @param {Array} segments - Array of Segments
214+
* @param {Array<PathSegment>} segments - Array of Segments
215215
*/
216216
function Path(start, end, segments) {
217217
(0, _classCallCheck3.default)(this, Path);

lib/v1/internal/connector.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ var Connection = function () {
303303
* failing, and the connection getting ejected from the session pool.
304304
*
305305
* @param err an error object, forwarded to all current and future subscribers
306-
* @private
306+
* @protected
307307
*/
308308

309309

@@ -327,6 +327,12 @@ var Connection = function () {
327327
value: function _handleMessage(msg) {
328328
var _this = this;
329329

330+
if (this._isBroken) {
331+
// ignore all incoming messages when this connection is broken. all previously pending observers failed
332+
// with the fatal error. all future observers will fail with same fatal error.
333+
return;
334+
}
335+
330336
var payload = msg.fields[0];
331337

332338
switch (msg.signature) {
@@ -339,7 +345,7 @@ var Connection = function () {
339345
try {
340346
this._currentObserver.onCompleted(payload);
341347
} finally {
342-
this._currentObserver = this._pendingObservers.shift();
348+
this._updateCurrentObserver();
343349
}
344350
break;
345351
case FAILURE:
@@ -348,7 +354,7 @@ var Connection = function () {
348354
this._currentFailure = (0, _error.newError)(payload.message, payload.code);
349355
this._currentObserver.onError(this._currentFailure);
350356
} finally {
351-
this._currentObserver = this._pendingObservers.shift();
357+
this._updateCurrentObserver();
352358
// Things are now broken. Pending observers will get FAILURE messages routed until
353359
// We are done handling this failure.
354360
if (!this._isHandlingFailure) {
@@ -375,7 +381,7 @@ var Connection = function () {
375381
try {
376382
if (this._currentFailure && this._currentObserver.onError) this._currentObserver.onError(this._currentFailure);else if (this._currentObserver.onError) this._currentObserver.onError(payload);
377383
} finally {
378-
this._currentObserver = this._pendingObservers.shift();
384+
this._updateCurrentObserver();
379385
}
380386
break;
381387
default:
@@ -533,6 +539,17 @@ var Connection = function () {
533539
return this._state.initializationCompleted();
534540
}
535541

542+
/*
543+
* Pop next pending observer form the list of observers and make it current observer.
544+
* @protected
545+
*/
546+
547+
}, {
548+
key: '_updateCurrentObserver',
549+
value: function _updateCurrentObserver() {
550+
this._currentObserver = this._pendingObservers.shift();
551+
}
552+
536553
/**
537554
* Synchronize - flush all queued outgoing messages and route their responses
538555
* to their respective handlers.
@@ -604,7 +621,8 @@ var ConnectionState = function () {
604621
}
605622

606623
/**
607-
* Wrap the given observer to track connection's initialization state.
624+
* Wrap the given observer to track connection's initialization state. Connection is closed by the server if
625+
* processing of INIT message fails so returned observer will handle initialization failure as a fatal error.
608626
* @param {StreamObserver} observer the observer used for INIT message.
609627
* @return {StreamObserver} updated observer.
610628
*/
@@ -627,8 +645,14 @@ var ConnectionState = function () {
627645
_this10._rejectPromise(error);
628646
_this10._rejectPromise = null;
629647
}
630-
if (observer && observer.onError) {
631-
observer.onError(error);
648+
649+
_this10._connection._updateCurrentObserver(); // make sure this same observer will not be called again
650+
try {
651+
if (observer && observer.onError) {
652+
observer.onError(error);
653+
}
654+
} finally {
655+
_this10._connection._handleFatalError(error);
632656
}
633657
},
634658
onCompleted: function onCompleted(metaData) {

lib/v1/internal/routing-util.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var CALL_GET_SERVERS = 'CALL dbms.cluster.routing.getServers';
5757
var GET_ROUTING_TABLE_PARAM = 'context';
5858
var CALL_GET_ROUTING_TABLE = 'CALL dbms.cluster.routing.getRoutingTable({' + GET_ROUTING_TABLE_PARAM + '})';
5959
var PROCEDURE_NOT_FOUND_CODE = 'Neo.ClientError.Procedure.ProcedureNotFound';
60+
var UNAUTHORIZED_CODE = 'Neo.ClientError.Security.Unauthorized';
6061

6162
var RoutingUtil = function () {
6263
function RoutingUtil(routingContext) {
@@ -84,10 +85,14 @@ var RoutingUtil = function () {
8485
if (error.code === PROCEDURE_NOT_FOUND_CODE) {
8586
// throw when getServers procedure not found because this is clearly a configuration issue
8687
throw (0, _error.newError)('Server ' + routerAddress + ' could not perform routing. ' + 'Make sure you are connecting to a causal cluster', _error.SERVICE_UNAVAILABLE);
88+
} else if (error.code === UNAUTHORIZED_CODE) {
89+
// auth error is a sign of a configuration issue, rediscovery should not proceed
90+
throw error;
91+
} else {
92+
// return nothing when failed to connect because code higher in the callstack is still able to retry with a
93+
// different session towards a different router
94+
return null;
8795
}
88-
// return nothing when failed to connect because code higher in the callstack is still able to retry with a
89-
// different session towards a different router
90-
return null;
9196
});
9297
}
9398
}, {

lib/v1/record.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ var Record = function () {
8989
* will get three arguments - the value, the key and this record, in that
9090
* order.
9191
*
92-
* @param visitor
92+
* @param {function(value: Object, key: string, record: Record)} visitor the function to apply to each field.
9393
*/
9494

9595

lib/v1/result-summary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function ProfiledPlan(profile) {
151151
};
152152

153153
/**
154-
* Get statistical information for a {Result}.
154+
* Get statistical information for a {@link Result}.
155155
* @access public
156156
*/
157157

0 commit comments

Comments
 (0)