Skip to content

Commit

Permalink
Add setting to allow user to change timeout. Fixes #809
Browse files Browse the repository at this point in the history
  • Loading branch information
PrashanthCorp committed Oct 24, 2018
1 parent def0429 commit 2e70221
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,11 @@
"description": "Command to execute or full path to folder and executable to start the Mongo shell, needed by some Mongo scrapbook commands. If empty, will search in the system path for 'mongo'.",
"default": null
},
"mongo.shell.timeoutInMilliseconds": {
"type": "number",
"description": "The duration allowed (in milliseconds) for the mongo shell to execute a command. Default value is 5 seconds",
"default": 5000
},
"cosmosDB.showExplorer": {
"type": "boolean",
"default": true,
Expand Down
1 change: 1 addition & 0 deletions src/extensionVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export namespace ext {
export namespace settingsKeys {
export const mongoShellPath = 'mongo.shell.path';
export const documentLabelFields = 'cosmosDB.documentLabelFields';
export const mongoShellTimeout = 'mongo.shell.timeoutInMilliseconds';

export namespace vsCode {
export const proxyStrictSSL = "http.proxyStrictSSL";
Expand Down
4 changes: 3 additions & 1 deletion src/mongo/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process';
import * as os from 'os';
import * as vscode from "vscode";
import { EventEmitter, window } from 'vscode';
import { ext } from '../extensionVariables';
import { IDisposable, toDisposable } from '../utils/vscodeUtils';
Expand Down Expand Up @@ -90,13 +91,14 @@ export class Shell {

return await new Promise<string>((c, e) => {
let executed = false;
const timeout: number = vscode.workspace.getConfiguration().get<number>(ext.settingsKeys.mongoShellTimeout);
const handler = setTimeout(
() => {
if (!executed) {
e(`Timed out executing MongoDB command "${script}"`);
}
},
5000);
timeout);
const disposable = this.onResult.event(result => {
disposable.dispose();

Expand Down

0 comments on commit 2e70221

Please sign in to comment.