Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase default connection timeout configuration value #482

Merged
merged 5 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,748 changes: 1,981 additions & 1,767 deletions package-lock.json

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@
"jsdelivr": "lib/browser/neo4j-web.js",
"types": "types/index.d.ts",
"devDependencies": {
"@babel/core": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/register": "^7.4.4",
"async": "^3.0.0",
"babel-eslint": "^10.0.1",
"@babel/core": "^7.5.5",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@babel/register": "^7.5.5",
"async": "^3.1.0",
"babel-eslint": "^10.0.3",
"babelify": "^10.0.0",
"browserify": "^16.2.3",
"browserify": "^16.5.0",
"browserify-transform-tools": "^1.7.0",
"esdoc": "^1.1.0",
"esdoc-importpath-plugin": "^1.0.2",
"esdoc-standard-plugin": "^1.0.0",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.17.2",
"eslint": "^6.2.2",
"eslint-config-standard": "^14.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jasmine": "^2.10.1",
"eslint-plugin-node": "^9.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"fancy-log": "^1.3.3",
"fs-extra": "^8.0.1",
"fs-extra": "^8.1.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-batch": "^1.0.5",
Expand All @@ -73,34 +73,34 @@
"gulp-typescript": "^5.0.1",
"gulp-uglify": "^3.0.2",
"gulp-watch": "^5.0.1",
"husky": "^2.3.0",
"husky": "^3.0.4",
"jasmine-console-reporter": "^3.1.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma": "^4.2.0",
"karma-browserify": "^6.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-edge-launcher": "^0.4.2",
"karma-firefox-launcher": "^1.1.0",
"karma-firefox-launcher": "^1.2.0",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^2.0.1",
"karma-source-map-support": "^1.4.0",
"karma-spec-reporter": "^0.0.32",
"lint-staged": "^8.1.7",
"lodash": "^4.17.11",
"lolex": "^4.0.1",
"lint-staged": "^9.2.5",
"lodash": "^4.17.15",
"lolex": "^4.2.0",
"minimist": "^1.2.0",
"mustache": "^3.0.1",
"prettier-eslint": "^8.8.2",
"prettier-eslint-cli": "^4.7.1",
"mustache": "^3.0.3",
"prettier-eslint": "^9.0.0",
"prettier-eslint-cli": "^5.0.0",
"run-sequence": "^2.2.1",
"semver": "^6.0.0",
"semver": "^6.3.0",
"tmp": "0.1.0",
"typescript": "^3.4.5",
"typescript": "^3.5.3",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"webpack": "^4.32.0"
"webpack": "^4.39.3"
},
"dependencies": {
"@babel/runtime": "^7.4.4",
"@babel/runtime": "^7.5.5",
"text-encoding-utf-8": "^1.0.2",
"uri-js": "^4.2.2"
}
Expand Down
4 changes: 2 additions & 2 deletions src/v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ const logging = {
*
* // Specify socket connection timeout in milliseconds. Numeric values are expected. Negative and zero values
* // result in no timeout being applied. Connection establishment will be then bound by the timeout configured
* // on the operating system level. Default value is 5000, which is 5 seconds.
* connectionTimeout: 5000, // 5 seconds
* // on the operating system level. Default value is 30000, which is 30 seconds.
* connectionTimeout: 30000, // 30 seconds
*
* // Make this driver always return native JavaScript numbers for integer values, instead of the
* // dedicated {@link Integer} class. Values that do not fit in native number bit range will be represented as
Expand Down
4 changes: 2 additions & 2 deletions src/v1/internal/bolt-protocol-v3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import RequestMessage from './request-message'

export default class BoltProtocol extends BoltProtocolV2 {
transformMetadata (metadata) {
if (metadata.t_first) {
if ('t_first' in metadata) {
// Bolt V3 uses shorter key 't_first' to represent 'result_available_after'
// adjust the key to be the same as in Bolt V1 so that ResultSummary can retrieve the value
metadata.result_available_after = metadata.t_first
delete metadata.t_first
}
if (metadata.t_last) {
if ('t_last' in metadata) {
// Bolt V3 uses shorter key 't_last' to represent 'result_consumed_after'
// adjust the key to be the same as in Bolt V1 so that ResultSummary can retrieve the value
metadata.result_consumed_after = metadata.t_last
Expand Down
2 changes: 1 addition & 1 deletion src/v1/internal/channel-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { newError, SERVICE_UNAVAILABLE } from '../error'
import { ENCRYPTION_OFF, ENCRYPTION_ON } from './util'

const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 5000 // 5 seconds by default
const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 30000 // 30 seconds by default

const ALLOWED_VALUES_ENCRYPTED = [
null,
Expand Down
18 changes: 10 additions & 8 deletions src/v1/result-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class ProfiledPlan {
this.operatorType = profile.operatorType
this.identifiers = profile.identifiers
this.arguments = profile.args
this.dbHits = profile.args.DbHits.toInt()
this.rows = profile.args.Rows.toInt()
this.dbHits = intValue(profile.args.DbHits)
this.rows = intValue(profile.args.Rows)
this.children = profile.children
? profile.children.map(child => new ProfiledPlan(child))
: []
Expand Down Expand Up @@ -201,11 +201,9 @@ class StatementStatistics {
}
Object.keys(statistics).forEach(index => {
// To camelCase
this._stats[index.replace(/(-\w)/g, m => m[1].toUpperCase())] = isInt(
this._stats[index.replace(/(-\w)/g, m => m[1].toUpperCase())] = intValue(
statistics[index]
)
? statistics[index].toInt()
: statistics[index]
})
}

Expand Down Expand Up @@ -322,9 +320,9 @@ class Notification {
return {}
}
return {
offset: pos.offset.toInt(),
line: pos.line.toInt(),
column: pos.column.toInt()
offset: intValue(pos.offset),
line: intValue(pos.line),
column: intValue(pos.column)
}
}
}
Expand All @@ -347,6 +345,10 @@ class ServerInfo {
}
}

function intValue (value) {
return isInt(value) ? value.toInt() : value
}

const statementType = {
READ_ONLY: 'r',
READ_WRITE: 'rw',
Expand Down
2 changes: 1 addition & 1 deletion test/internal/channel-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('ChannelConfig', () => {
it('should have connection timeout by default', () => {
const config = new ChannelConfig(null, {}, '')

expect(config.connectionTimeout).toEqual(5000)
expect(config.connectionTimeout).toEqual(30000)
})

it('should respect configured connection timeout', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/internal/node/direct.driver.boltkit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ describe('direct driver with stub server', () => {

boltStub.run(() => {
const driver = boltStub.newDriver('bolt://127.0.0.1:9001')
const session = driver.session()
const session = driver.session(neo4j.session.READ)
session.run('MATCH (n) RETURN n.name').catch(error => {
expect(error.code).toEqual(neo4j.error.SERVICE_UNAVAILABLE)

Expand Down
8 changes: 4 additions & 4 deletions test/internal/node/routing.driver.boltkit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,15 @@ describe('routing driver with stub server', () => {
9001
)
const readServer = boltStub.start(
'./test/resources/boltstub/dead_read_server.script',
'./test/resources/boltstub/dead_write_server.script',
9007
)

boltStub.run(() => {
const driver = boltStub.newDriver('bolt+routing://127.0.0.1:9001')
// When
const session = driver.session(neo4j.session.WRITE)
session.run('MATCH (n) RETURN n.name').catch(err => {
session.run("CREATE (n {name:'Bob'})").catch(err => {
expect(err.code).toEqual(neo4j.error.SESSION_EXPIRED)
driver.close()
seedServer.exit(code1 => {
Expand Down Expand Up @@ -1909,7 +1909,7 @@ describe('routing driver with stub server', () => {

boltStub.run(() => {
const driver = boltStub.newDriver('bolt+routing://127.0.0.1:9001')
const session = driver.session()
const session = driver.session(neo4j.session.READ)
session.run('MATCH (n) RETURN n.name AS name').then(result => {
const names = result.records.map(record => record.get('name'))
expect(names).toEqual(['Alice', 'Bob', 'Eve'])
Expand Down Expand Up @@ -2758,7 +2758,7 @@ describe('routing driver with stub server', () => {
'./test/resources/boltstub/address_unavailable_template.script.mst'
const server = boltStub.startWithTemplate(
serverTemplateScript,
{ query: query },
{ query: query, mode: accessMode === READ ? '"mode": "r"' : '' },
serverPort
)

Expand Down
6 changes: 4 additions & 2 deletions test/resources/boltstub/acquire_endpoints.script
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
!: AUTO INIT
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO PULL_ALL
!: AUTO GOODBYE

C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}}
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
PULL_ALL
S: SUCCESS {"fields": ["ttl", "servers"]}
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9007","127.0.0.1:9008"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9005","127.0.0.1:9006"], "role": "READ"},{"addresses": ["127.0.0.1:9001","127.0.0.1:9002","127.0.0.1:9003"], "role": "ROUTE"}]]
Expand Down
6 changes: 4 additions & 2 deletions test/resources/boltstub/acquire_endpoints_and_exit.script
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
!: AUTO INIT
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO PULL_ALL
!: AUTO GOODBYE

C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}}
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
PULL_ALL
S: SUCCESS {"fields": ["ttl", "servers"]}
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9007","127.0.0.1:9008"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9005","127.0.0.1:9006"], "role": "READ"},{"addresses": ["127.0.0.1:9001","127.0.0.1:9002","127.0.0.1:9003"], "role": "ROUTE"}]]
Expand Down
1 change: 1 addition & 0 deletions test/resources/boltstub/acquire_endpoints_v3.script
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
!: BOLT 3
!: AUTO RESET
!: AUTO GOODBYE

C: HELLO {"scheme": "basic", "principal": "neo4j", "credentials": "password", "user_agent": "neo4j-javascript/0.0.0-dev"}
S: SUCCESS {"server": "Neo4j/9.9.9", "connection_id": "bolt-123456789"}
Expand Down
1 change: 1 addition & 0 deletions test/resources/boltstub/acquire_endpoints_v3_empty.script
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO GOODBYE

C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
PULL_ALL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO GOODBYE

C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
PULL_ALL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
!: BOLT 3
!: AUTO HELLO
!: AUTO GOODBYE

C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
PULL_ALL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
!: AUTO INIT
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO PULL_ALL
!: AUTO GOODBYE

C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}}
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
PULL_ALL
S: SUCCESS {"fields": ["ttl", "servers"]}
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9007"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9005"], "role": "READ"},{"addresses": ["127.0.0.1:9001","127.0.0.1:9002"], "role": "ROUTE"}]]
Expand Down
12 changes: 7 additions & 5 deletions test/resources/boltstub/address_unavailable_template.script.mst
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
!: AUTO INIT
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO PULL_ALL
!: AUTO RUN "ROLLBACK" {}
!: AUTO RUN "BEGIN" {}
!: AUTO RUN "COMMIT" {}
!: AUTO ROLLBACK
!: AUTO BEGIN
!: AUTO COMMIT
!: AUTO GOODBYE

C: RUN "{{{query}}}" {}
C: RUN "{{{query}}}" {} { {{{mode}}} }
C: PULL_ALL
S: FAILURE {"code": "Neo.TransientError.General.DatabaseUnavailable", "message": "Database is busy doing store copy"}
S: IGNORED
8 changes: 5 additions & 3 deletions test/resources/boltstub/dead_read_server.script
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
!: AUTO INIT
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO PULL_ALL
!: AUTO RUN "BEGIN" {}
!: AUTO BEGIN
!: AUTO GOODBYE

C: RUN "MATCH (n) RETURN n.name" {}
C: RUN "MATCH (n) RETURN n.name" {} {"mode": "r"}
C: PULL_ALL
S: <EXIT>
5 changes: 3 additions & 2 deletions test/resources/boltstub/dead_routing_server.script
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
!: AUTO INIT
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO PULL_ALL

C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}}
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
C: PULL_ALL
S: <EXIT>
8 changes: 5 additions & 3 deletions test/resources/boltstub/dead_write_server.script
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
!: AUTO INIT
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO PULL_ALL
!: AUTO RUN "BEGIN" {}
!: AUTO BEGIN
!: AUTO GOODBYE

C: RUN "CREATE (n {name:'Bob'})" {}
C: RUN "CREATE (n {name:'Bob'})" {} {}
C: PULL_ALL
S: <EXIT>
8 changes: 5 additions & 3 deletions test/resources/boltstub/discover_ipv6_servers_and_read.script
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
!: AUTO INIT
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO PULL_ALL
!: AUTO GOODBYE

C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}}
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
PULL_ALL
S: SUCCESS {"fields": ["ttl", "servers"]}
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9001", "[::1]:9001"],"role": "READ"}, {"addresses": ["[2001:db8:a0b:12f0::1]:9002","[3731:54:65fe:2::a7]:9003"], "role": "WRITE"},{"addresses": ["[ff02::1]:9001","[684D:1111:222:3333:4444:5555:6:77]:9002","[::1]:9003"], "role": "ROUTE"}]]
SUCCESS {}
C: RUN "MATCH (n) RETURN n.name" {}
C: RUN "MATCH (n) RETURN n.name" {} {"mode": "r"}
PULL_ALL
S: SUCCESS {"fields": ["n.name"]}
SUCCESS {}
8 changes: 5 additions & 3 deletions test/resources/boltstub/discover_new_servers.script
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
!: AUTO INIT
!: BOLT 3
!: AUTO HELLO
!: AUTO RESET
!: AUTO PULL_ALL
!: AUTO GOODBYE

C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}}
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
PULL_ALL
S: SUCCESS {"fields": ["ttl", "servers"]}
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9001"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9005","127.0.0.1:9003"], "role": "READ"},{"addresses": ["127.0.0.1:9004","127.0.0.1:9002","127.0.0.1:9003"], "role": "ROUTE"}]]
SUCCESS {}
C: RUN "MATCH (n) RETURN n.name" {}
C: RUN "MATCH (n) RETURN n.name" {} {}
PULL_ALL
S: SUCCESS {"fields": ["n.name"]}
SUCCESS {}
Loading