Skip to content

Commit

Permalink
Fix comm_info_request content to conform to spec in a backwards-compa…
Browse files Browse the repository at this point in the history
…tible way.

This workaround should be removed in services 5.0.

Fixes jupyterlab#6947
  • Loading branch information
jasongrout committed Aug 5, 2019
1 parent 32451a6 commit 62c7cdb
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions packages/services/src/kernel/messages.ts
Expand Up @@ -143,6 +143,18 @@ export namespace KernelMessage {
): T;

export function createMessage<T extends Message>(options: IOptions<T>): T {
// Backwards compatibility workaround for services 4.0 defining the wrong
// comm_info_request content. This should be removed with the deprecated
// `target` content option in services 5.0. See
// https://github.com/jupyterlab/jupyterlab/issues/6947
if (options.msgType === 'comm_info_request') {
const content = options.content as ICommInfoRequestMsg['content'];
if (content.target_name === undefined) {
content.target_name = content.target;
}
delete content.target;
}

return {
buffers: options.buffers || [],
channel: options.channel,
Expand Down Expand Up @@ -1076,10 +1088,22 @@ export namespace KernelMessage {
*
* **See also:** [[ICommInfoReplyMsg]], [[IKernel.commInfo]]
*/

export interface ICommInfoRequestMsg
extends IShellMessage<'comm_info_request'> {
content: {
/**
* The comm target name to filter returned comms
*/
target_name?: string;

/**
* Filter for returned comms
*
* @deprecated - this is a non-standard field. Use target_name instead
*
* #### Notes
* See https://github.com/jupyterlab/jupyterlab/issues/6947
*/
target?: string;
};
}
Expand All @@ -1091,7 +1115,6 @@ export namespace KernelMessage {
*
* **See also:** [[ICommInfoRequest]], [[IKernel.commInfo]]
*/

export interface ICommInfoReply extends IReplyOkContent {
/**
* Mapping of comm ids to target names.
Expand Down

0 comments on commit 62c7cdb

Please sign in to comment.