Skip to content

Commit bb08240

Browse files
authored
Debug and variable test failures on nightly (microsoft#11848)
* Don't send messagse after shutdown * Make sure smoke tests pass all the time * Fix nightly intermittent debug failures. * Fix sonar bug
1 parent 3d7c03c commit bb08240

File tree

9 files changed

+26
-15
lines changed

9 files changed

+26
-15
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ jobs:
495495
DISPLAY: 10
496496
uses: GabrielBB/xvfb-action@v1.0
497497
with:
498-
run: node ./out/test/smokeTest.js
498+
run: node --no-force-async-hooks-checks ./out/test/smokeTest.js
499499

500500
coverage:
501501
name: Coverage reports upload

build/ci/templates/test_phases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ steps:
506506
npm run package
507507
npx gulp clean:cleanExceptTests
508508
cp -r ./tmp/test ./out/test
509-
node ./out/test/smokeTest.js
509+
node --no-force-async-hooks-checks ./out/test/smokeTest.js
510510
displayName: 'Run Smoke Tests'
511511
condition: and(succeeded(), contains(variables['TestsToRun'], 'testSmoke'))
512512
env:

src/client/datascience/jupyter/debuggerVariables.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class DebuggerVariables implements IConditionalJupyterVariables, DebugAda
115115
end: number
116116
): Promise<{}> {
117117
// Run the get dataframe rows script
118-
if (!this.debugService.activeDebugSession) {
118+
if (!this.debugService.activeDebugSession || targetVariable.columns === undefined) {
119119
// No active server just return no rows
120120
return {};
121121
}
@@ -161,7 +161,7 @@ export class DebuggerVariables implements IConditionalJupyterVariables, DebugAda
161161
// When the initialize response comes back, indicate we have started.
162162
if (message.type === 'response' && message.command === 'initialize') {
163163
this.debuggingStarted = true;
164-
} else if (message.type === 'response' && message.command === 'variables') {
164+
} else if (message.type === 'response' && message.command === 'variables' && message.body) {
165165
// If using the interactive debugger, update our variables.
166166
// tslint:disable-next-line: no-suspicious-comment
167167
// TODO: Figure out what resource to use

src/client/datascience/jupyterDebugService.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,19 @@ export class JupyterDebugService implements IJupyterDebugService, IDisposable {
337337

338338
private sendMessage(command: string, args?: any): Promise<any> {
339339
const response = createDeferred<any>();
340-
const disposable = this.sessionTerminatedEvent.event(() => response.resolve());
341-
this.protocolParser.once(`response_${command}`, (resp: any) => {
342-
this.sendToTrackers(resp);
343-
traceInfo(`Received response from debugger: ${JSON.stringify(args)}`);
344-
disposable.dispose();
345-
response.resolve(resp.body);
340+
const disposable = this.sessionTerminatedEvent.event(() => {
341+
response.resolve({ body: {} });
346342
});
347-
this.socket!.on('error', (err) => response.reject(err)); // NOSONAR
343+
const sequenceNumber = this.sequence;
344+
this.protocolParser.on(`response_${command}`, (resp: any) => {
345+
if (resp.request_seq === sequenceNumber) {
346+
this.sendToTrackers(resp);
347+
traceInfo(`Received response from debugger: ${JSON.stringify(args)}`);
348+
disposable.dispose();
349+
response.resolve(resp.body);
350+
}
351+
});
352+
this.socket?.on('error', (err) => response.reject(err)); // NOSONAR
348353
this.emitMessage(command, args).catch((exc) => {
349354
traceError(`Exception attempting to emit ${command} to debugger: `, exc);
350355
});

src/datascience-ui/interactive-common/redux/reducers/variables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function handleRestarted(arg: VariableReducerArg): IVariableState {
147147
});
148148
return {
149149
...result,
150-
currentExecutionCount: 0,
150+
currentExecutionCount: -1,
151151
variables: []
152152
};
153153
}

src/datascience-ui/interactive-common/redux/store.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ function createTestMiddleware(): Redux.Middleware<{}, IStore> {
183183
}
184184

185185
// Indicate variables complete
186-
if (!fastDeepEqual(prevState.variables.variables, afterState.variables.variables)) {
186+
if (
187+
(!fastDeepEqual(prevState.variables.variables, afterState.variables.variables) ||
188+
prevState.variables.currentExecutionCount !== afterState.variables.currentExecutionCount) &&
189+
action.type === InteractiveWindowMessages.GetVariablesResponse
190+
) {
187191
sendMessage(InteractiveWindowMessages.VariablesComplete);
188192
}
189193

src/test/datascience/debugger.functional.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ suite('DataScience Debugger tests', () => {
190190
if (stepAndVerify && ioc.wrapper && !ioc.mockJupyter) {
191191
// Verify variables work
192192
openVariableExplorer(ioc.wrapper);
193-
const variableRefresh = waitForMessage(ioc, InteractiveWindowMessages.VariablesComplete);
194193
breakPromise = createDeferred<void>();
195194
await jupyterDebuggerService?.step();
196195
await breakPromise.promise;
196+
await waitForMessage(ioc, InteractiveWindowMessages.VariablesComplete);
197+
const variableRefresh = waitForMessage(ioc, InteractiveWindowMessages.VariablesComplete);
197198
await jupyterDebuggerService?.requestVariables();
198199
await variableRefresh;
199200

src/test/datascience/variableTestHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function verifyAfterStep(
3737
docManager.addDocument('a=1\na', file.fsPath);
3838
const debugPromise = interactive.debugCode('a=1\na', file.fsPath, 1, undefined, undefined);
3939
await debuggerBroke.promise;
40-
const variableRefresh = waitForVariablesUpdated(ioc, 2); // Two times. Once for the initial refresh and another for the values.
40+
const variableRefresh = waitForVariablesUpdated(ioc);
4141
await jupyterDebugger.requestVariables(); // This is necessary because not running inside of VS code. Normally it would do this.
4242
await variableRefresh;
4343
wrapper.update();

src/test/datascience/variableexplorer.functional.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ myDict = {'a': 1}`;
329329

330330
// Restart the kernel and repeat
331331
const interactive = await getOrCreateInteractiveWindow(ioc);
332+
332333
const variablesComplete = waitForMessage(ioc, InteractiveWindowMessages.VariablesComplete);
333334
await interactive.restartKernel();
334335
await variablesComplete; // Restart should cause a variable refresh

0 commit comments

Comments
 (0)