Skip to content
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
1 change: 1 addition & 0 deletions news/2 Fixes/7638.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a hang in the Interactive window when connecting guest to host after the host has already started the interactive window.
4 changes: 4 additions & 0 deletions src/client/datascience/jupyter/jupyterServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ export class JupyterServerBase implements INotebookServer {
return this.notebooks.get(resource.toString());
}

protected getNotebooks(): INotebook[] {
return [...this.notebooks.values()];
}

protected setNotebook(resource: Uri, notebook: INotebook) {
const oldDispose = notebook.dispose;
notebook.dispose = () => {
Expand Down
11 changes: 11 additions & 0 deletions src/client/datascience/jupyter/liveshare/guestJupyterServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ export class GuestJupyterServer
return result;
}

public async onSessionChange(api: vsls.LiveShare | null): Promise<void> {
Copy link
Member Author

@IanMatthewHuff IanMatthewHuff Oct 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rich, I'm a bit unsure if the guest role needs this. It makes sense structurally to me, but is not needed for this fix.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, but It won't hurt.


In reply to: 331299771 [](ancestors = 331299771)

await super.onSessionChange(api);

this.notebooks.forEach(async notebook => {
const guestNotebook = notebook as GuestJupyterNotebook;
if (guestNotebook) {
await guestNotebook.onSessionChange(api);
}
});
}

public async getNotebook(resource: Uri): Promise<INotebook | undefined> {
return this.notebooks.get(resource.toString());
}
Expand Down
11 changes: 11 additions & 0 deletions src/client/datascience/jupyter/liveshare/hostJupyterServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ export class HostJupyterServer
}
}

public async onSessionChange(api: vsls.LiveShare | null): Promise<void> {
await super.onSessionChange(api);

this.getNotebooks().forEach(async notebook => {
const hostNotebook = notebook as HostJupyterNotebook;
if (hostNotebook) {
await hostNotebook.onSessionChange(api);
}
});
}

public async onDetach(api: vsls.LiveShare | null): Promise<void> {
await super.onDetach(api);

Expand Down
17 changes: 17 additions & 0 deletions src/test/datascience/liveshare.functional.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,23 @@ suite('DataScience LiveShare tests', () => {
verifyHtmlOnCell(guestContainer.wrapper!, 'InteractiveCell', '<span>1</span>', CellPosition.Last);
});

test('Host starts LiveShare after starting Jupyter', async() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified this test fails with a hang of the guest connection to the host without my fix, and passes with my fix.

addMockData(hostContainer!, 'a=1\na', 1);
addMockData(hostContainer!, 'b=2\nb', 2);
await getOrCreateInteractiveWindow(vsls.Role.Host);
let wrapper = await addCodeToRole(vsls.Role.Host, 'a=1\na');
verifyHtmlOnCell(wrapper, 'InteractiveCell', '<span>1</span>', CellPosition.Last);

await startSession(vsls.Role.Host);
await getOrCreateInteractiveWindow(vsls.Role.Guest);
await startSession(vsls.Role.Guest);

wrapper = await addCodeToRole(vsls.Role.Host, 'b=2\nb');

assert.ok(guestContainer.wrapper, 'Guest wrapper not created');
verifyHtmlOnCell(guestContainer.wrapper!, 'InteractiveCell', '<span>2</span>', CellPosition.Last);
});

test('Host Shutdown and Run', async () => {
// Should only need mock data in host
addMockData(hostContainer!, 'a=1\na', 1);
Expand Down