Skip to content

Commit 412d730

Browse files
committed
Set default connection timeout to 5 seconds
To align the value with other drivers.
1 parent 56941b8 commit 412d730

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/v1/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const USER_AGENT = "neo4j-javascript/" + VERSION;
144144
*
145145
* // Specify socket connection timeout in milliseconds. Non-numeric, negative and zero values are treated as an
146146
* // infinite timeout. Connection will be then bound by the timeout configured on the operating system level.
147-
* // Timeout value should be numeric and greater or equal to zero.
147+
* // Timeout value should be numeric and greater or equal to zero. Default value is 5000 which is 5 seconds.
148148
* connectionTimeout: 5000, // 5 seconds
149149
* }
150150
*

src/v1/internal/ch-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import hasFeature from './features';
2121
import {SERVICE_UNAVAILABLE} from '../error';
2222

23-
const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 0; // turned off by default
23+
const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 5000; // 5 seconds by default
2424

2525
export default class ChannelConfig {
2626

test/internal/ch-config.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,16 @@ describe('ChannelConfig', () => {
110110
expect(config.connectionErrorCode).toEqual(SERVICE_UNAVAILABLE);
111111
});
112112

113+
it('should have connection timeout by default', () => {
114+
const config = new ChannelConfig('', 42, {}, '');
115+
116+
expect(config.connectionTimeout).toEqual(5000);
117+
});
118+
119+
it('should respect configured connection timeout', () => {
120+
const config = new ChannelConfig('', 42, {connectionTimeout: 424242}, '');
121+
122+
expect(config.connectionTimeout).toEqual(424242);
123+
});
124+
113125
});

0 commit comments

Comments
 (0)