Skip to content

Commit fa780de

Browse files
authored
Refactor experimental debugger (#910)
Fixes DonJayamanne#822 Removes some of the unwanted setTimeouts (work arounds) with changes to upstream PTVSD
1 parent fb07769 commit fa780de

8 files changed

Lines changed: 290 additions & 144 deletions

File tree

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,6 @@
17901790
"md5": "^2.2.1",
17911791
"minimatch": "^3.0.3",
17921792
"named-js-regexp": "^1.3.1",
1793-
"once": "^1.4.0",
17941793
"opn": "^5.1.0",
17951794
"pidusage": "^1.2.0",
17961795
"reflect-metadata": "^0.1.12",
@@ -1825,7 +1824,6 @@
18251824
"@types/md5": "^2.1.32",
18261825
"@types/mocha": "^2.2.43",
18271826
"@types/node": "^6.0.40",
1828-
"@types/once": "^1.4.0",
18291827
"@types/semver": "^5.4.0",
18301828
"@types/shortid": "0.0.29",
18311829
"@types/sinon": "^2.3.2",

src/client/common/core.utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
'use strict';
5+
6+
export async function sleep(timeout: number) {
7+
return new Promise(resolve => setTimeout(resolve, timeout));
8+
}
9+
10+
// tslint:disable-next-line:no-empty
11+
export function noop() { }

src/client/common/net/socket/socketServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { EventEmitter } from 'events';
22
import { injectable } from 'inversify';
33
import * as net from 'net';
4+
import { noop } from '../../core.utils';
45
import { createDeferred, Deferred } from '../../helpers';
56
import { ISocketServer } from '../../types';
67

@@ -56,8 +57,7 @@ export class SocketServer extends EventEmitter implements ISocketServer {
5657
client.on('data', (data: Buffer) => {
5758
this.emit('data', client, data);
5859
});
59-
// tslint:disable-next-line:no-empty
60-
client.on('error', (err: Error) => { });
60+
client.on('error', (err: Error) => noop);
6161

6262
client.on('timeout', d => {
6363
// let msg = "Debugger client timedout, " + d;

src/client/common/process/currentProcess.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import { EnvironmentVariables } from '../variables/types';
44

55
@injectable()
66
export class CurrentProcess implements ICurrentProcess {
7+
public on = (event: string | symbol, listener: Function): this => {
8+
process.on(event, listener);
9+
// tslint:disable-next-line:no-any
10+
return process as any;
11+
}
712
public get env(): EnvironmentVariables {
813
return process.env;
914
}

src/client/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export interface ICurrentProcess {
9191
readonly argv: string[];
9292
readonly stdout: NodeJS.WriteStream;
9393
readonly stdin: NodeJS.ReadStream;
94+
on(event: string | symbol, listener: Function): this;
9495
}
9596

9697
export interface IPythonSettings {

src/client/debugger/mainV2.ts

Lines changed: 268 additions & 136 deletions
Large diffs are not rendered by default.

src/test/mocks/process.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import { EnvironmentVariables } from '../../client/common/variables/types';
99
@injectable()
1010
export class MockProcess implements ICurrentProcess {
1111
constructor(public env: EnvironmentVariables = { ...process.env }) { }
12+
public on(event: string | symbol, listener: Function): this {
13+
return this;
14+
}
1215
public get argv(): string[] {
1316
return [];
1417
}

yarn.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@
9494
version "6.0.95"
9595
resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.95.tgz#0d027612a77c55b84497ff90a4a7d597e5ac0fab"
9696

97-
"@types/once@^1.4.0":
98-
version "1.4.0"
99-
resolved "https://registry.yarnpkg.com/@types/once/-/once-1.4.0.tgz#7bfe3d99a0951f3141bac2617c9827525788b8f5"
100-
10197
"@types/semver@^5.4.0":
10298
version "5.4.0"
10399
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.4.0.tgz#f3658535af7f1f502acd6da7daf405ffeb1f7ee4"

0 commit comments

Comments
 (0)