Skip to content

Commit

Permalink
fix(protocol): Latest debugger should still work with older MC client…
Browse files Browse the repository at this point in the history
…s if possible. (#228)

Send incoming protocol version back to MC after determining
capabilities.
  • Loading branch information
chmeyer-ms authored Sep 26, 2024
1 parent 68ed206 commit 6410e8c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,13 @@ export class Session extends DebugSession {
//
}

private onConnectionComplete(targetModuleUuid?: string, passcode?: string) {
private onConnectionComplete(protocolVersion?: number, targetModuleUuid?: string, passcode?: string) {
this._targetModuleUuid = targetModuleUuid;

// respond with protocol version and chosen debugee target
this.sendDebuggeeMessage({
type: 'protocol',
version: Session.DEBUGGER_PROTOCOL_VERSION,
version: protocolVersion,
target_module_uuid: targetModuleUuid,
passcode: passcode,
});
Expand Down Expand Up @@ -769,7 +769,7 @@ export class Session extends DebugSession {
this.terminateSession('protocol mismatch. Update Debugger Extension.', LogLevel.Error);
} else {
if (protocolCapabilities.version == ProtcolVersion.SupportTargetModuleUuid) {
this.onConnectionComplete(this._targetModuleUuid, undefined);
this.onConnectionComplete(protocolCapabilities.version, undefined);
} else if (protocolCapabilities.version >= ProtcolVersion.SupportTargetSelection) {
// no add-ons found, nothing to do
if (!protocolCapabilities.plugins || protocolCapabilities.plugins.length === 0) {
Expand All @@ -786,7 +786,7 @@ export class Session extends DebugSession {
plugin => plugin.module_uuid === this._targetModuleUuid
);
if (isValidTarget) {
this.onConnectionComplete(this._targetModuleUuid, passcode);
this.onConnectionComplete(protocolCapabilities.version, this._targetModuleUuid, passcode);
return;
} else {
this.showNotification(
Expand All @@ -795,7 +795,11 @@ export class Session extends DebugSession {
);
}
} else if (protocolCapabilities.plugins.length === 1) {
this.onConnectionComplete(protocolCapabilities.plugins[0].module_uuid, passcode);
this.onConnectionComplete(
protocolCapabilities.version,
protocolCapabilities.plugins[0].module_uuid,
passcode
);
return;
} else {
this.showNotification(
Expand All @@ -813,7 +817,7 @@ export class Session extends DebugSession {
);
return;
}
this.onConnectionComplete(targetUuid, passcode);
this.onConnectionComplete(protocolCapabilities.version, targetUuid, passcode);
} else {
this.terminateSession('protocol unsupported. Update Debugger Extension.', LogLevel.Error);
}
Expand Down

0 comments on commit 6410e8c

Please sign in to comment.