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

Add configuration for websocket timeout #1176

Merged
merged 3 commits into from
Nov 3, 2020
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
13,301 changes: 6,686 additions & 6,615 deletions docs/api.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/browser/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const config = <RemoteConfig>parseArgs(parseQuery());
const channel = new Channel({
url: config.serverUrl,
sessionId: config.sessionId,
port: config.socketPort
port: config.socketPort,
timeout: config.socketTimeout
});

function displayMessage(message: string) {
Expand Down
7 changes: 5 additions & 2 deletions src/lib/RemoteSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ export default class RemoteSuite extends Suite {
runInSync: config.runInSync || false,
serverUrl: serverUrl.href,
sessionId: sessionId,
socketPort: server.socketPort
socketPort: server.socketPort,
socketTimeout: config.socketTimeout
};

// Do some pre-serialization of the options
Expand Down Expand Up @@ -239,7 +240,8 @@ export default class RemoteSuite extends Suite {
reporters: true,
serverUrl: true,
sessionId: true,
socketPort: true
socketPort: true,
socketTimeout: true
};

// Pass all non-excluded keys to the remote config
Expand Down Expand Up @@ -304,4 +306,5 @@ export interface RemoteConfig extends Config {
sessionId: string;
runInSync: boolean;
socketPort?: number;
socketTimeout?: number;
}
6 changes: 3 additions & 3 deletions src/lib/channels/WebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export default class WebSocketChannel extends BaseChannel {

constructor(options: ChannelOptions) {
super(options);

if (this.timeout == null) {
this.timeout = 10000;
this.timeout = 10000;
if (options.timeout !== undefined) {
this.timeout = options.timeout;
}

if (!options.port) {
Expand Down
6 changes: 6 additions & 0 deletions src/lib/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ export interface Config extends ResourceConfig {
*/
socketPort?: number;

/**
* The number of milliseconds to wait before a websocket message is considered
* to be timed out.
*/
socketTimeout?: number;

/**
* The Dig Dug tunnel class to use for WebDriver testing.
*
Expand Down
3 changes: 2 additions & 1 deletion src/lib/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ export function processOption<C extends Config>(
case 'heartbeatInterval':
case 'maxConcurrency':
case 'serverPort':
case 'socketPort': {
case 'socketPort':
case 'socketTimeout': {
setOption(config, name, parseValue(name, value, 'number'));
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/executors/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default class Node extends Executor<NodeEvents, Config, NodePlugins> {
serverPort: 9000,
serverUrl: '',
socketPort: 9001,
socketTimeout: 10000,
tunnel: 'selenium',
tunnelOptions: { tunnelId: String(Date.now()) }
});
Expand Down
6 changes: 6 additions & 0 deletions src/schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@
"examples": [9001]
},

"socketTimeout": {
"description": "The number of milliseconds to wait before a websocket message is considered to be timed out",
"type": "integer",
"examples": [10000]
},

"suites": { "$ref": "#/definitions/suitesProperty" },
"suites+": { "$ref": "#/definitions/suitesProperty+" },

Expand Down
1 change: 1 addition & 0 deletions tests/unit/lib/executors/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ registerSuite('lib/executors/Node', function() {
maxConcurrency: numberTest('maxConcurrency'),
serverPort: numberTest('serverPort'),
socketPort: numberTest('socketPort'),
socketTimeout: numberTest('socketTimeout'),

functionalBaseUrl: stringTest('functionalBaseUrl'),
proxy: stringTest('proxy'),
Expand Down