mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode cfc1ab4c5f816765b91fb7ead3c3427a7c8581a3
This commit is contained in:
@@ -76,7 +76,7 @@ export class ExtensionHostMain {
|
||||
|
||||
// error forwarding and stack trace scanning
|
||||
Error.stackTraceLimit = 100; // increase number of stack frames (from 10, https://github.com/v8/v8/wiki/Stack-Trace-API)
|
||||
const extensionErrors = new WeakMap<Error, IExtensionDescription>();
|
||||
const extensionErrors = new WeakMap<Error, IExtensionDescription | undefined>();
|
||||
this._extensionService.getExtensionPathIndex().then(map => {
|
||||
(<any>Error).prepareStackTrace = (error: Error, stackTrace: errors.V8CallSite[]) => {
|
||||
let stackTraceMessage = '';
|
||||
|
||||
@@ -27,6 +27,10 @@ function safeStringify(obj: any, replacer: JSONStringifyReplacer | null): string
|
||||
}
|
||||
}
|
||||
|
||||
function stringify(obj: any, replacer: JSONStringifyReplacer | null): string {
|
||||
return JSON.stringify(obj, <(key: string, value: any) => any>replacer);
|
||||
}
|
||||
|
||||
function createURIReplacer(transformer: IURITransformer | null): JSONStringifyReplacer | null {
|
||||
if (!transformer) {
|
||||
return null;
|
||||
@@ -412,6 +416,8 @@ export class RPCProtocol extends Disposable implements IRPCProtocol {
|
||||
return Promise.reject<any>(errors.canceled());
|
||||
}
|
||||
|
||||
const serializedRequestArguments = MessageIO.serializeRequestArguments(args, this._uriReplacer);
|
||||
|
||||
const req = ++this._lastMessageId;
|
||||
const callId = String(req);
|
||||
const result = new LazyPromise();
|
||||
@@ -428,7 +434,7 @@ export class RPCProtocol extends Disposable implements IRPCProtocol {
|
||||
|
||||
this._pendingRPCReplies[callId] = result;
|
||||
this._onWillSendRequest(req);
|
||||
const msg = MessageIO.serializeRequest(req, rpcId, methodName, args, !!cancellationToken, this._uriReplacer);
|
||||
const msg = MessageIO.serializeRequest(req, rpcId, methodName, serializedRequestArguments, !!cancellationToken);
|
||||
if (this._logger) {
|
||||
this._logger.logOutgoing(msg.byteLength, req, RequestInitiator.LocalSide, `request: ${getStringIdentifierForProxy(rpcId)}.${methodName}(`, args);
|
||||
}
|
||||
@@ -600,6 +606,8 @@ class MessageBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
type SerializedRequestArguments = { type: 'mixed'; args: VSBuffer[]; argsType: ArgType[]; } | { type: 'simple'; args: string; };
|
||||
|
||||
class MessageIO {
|
||||
|
||||
private static _arrayContainsBufferOrUndefined(arr: any[]): boolean {
|
||||
@@ -614,7 +622,7 @@ class MessageIO {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static serializeRequest(req: number, rpcId: number, method: string, args: any[], usesCancellationToken: boolean, replacer: JSONStringifyReplacer | null): VSBuffer {
|
||||
public static serializeRequestArguments(args: any[], replacer: JSONStringifyReplacer | null): SerializedRequestArguments {
|
||||
if (this._arrayContainsBufferOrUndefined(args)) {
|
||||
let massagedArgs: VSBuffer[] = [];
|
||||
let massagedArgsType: ArgType[] = [];
|
||||
@@ -627,13 +635,27 @@ class MessageIO {
|
||||
massagedArgs[i] = VSBuffer.alloc(0);
|
||||
massagedArgsType[i] = ArgType.Undefined;
|
||||
} else {
|
||||
massagedArgs[i] = VSBuffer.fromString(safeStringify(arg, replacer));
|
||||
massagedArgs[i] = VSBuffer.fromString(stringify(arg, replacer));
|
||||
massagedArgsType[i] = ArgType.String;
|
||||
}
|
||||
}
|
||||
return this._requestMixedArgs(req, rpcId, method, massagedArgs, massagedArgsType, usesCancellationToken);
|
||||
return {
|
||||
type: 'mixed',
|
||||
args: massagedArgs,
|
||||
argsType: massagedArgsType
|
||||
};
|
||||
}
|
||||
return this._requestJSONArgs(req, rpcId, method, safeStringify(args, replacer), usesCancellationToken);
|
||||
return {
|
||||
type: 'simple',
|
||||
args: stringify(args, replacer)
|
||||
};
|
||||
}
|
||||
|
||||
public static serializeRequest(req: number, rpcId: number, method: string, serializedArgs: SerializedRequestArguments, usesCancellationToken: boolean): VSBuffer {
|
||||
if (serializedArgs.type === 'mixed') {
|
||||
return this._requestMixedArgs(req, rpcId, method, serializedArgs.args, serializedArgs.argsType, usesCancellationToken);
|
||||
}
|
||||
return this._requestJSONArgs(req, rpcId, method, serializedArgs.args, usesCancellationToken);
|
||||
}
|
||||
|
||||
private static _requestJSONArgs(req: number, rpcId: number, method: string, args: string, usesCancellationToken: boolean): VSBuffer {
|
||||
|
||||
@@ -42,6 +42,7 @@ import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IOutputChannelRegistry, Extensions } from 'vs/workbench/services/output/common/output';
|
||||
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
|
||||
export class ExtensionHostProcessWorker implements IExtensionHostStarter {
|
||||
|
||||
@@ -78,7 +79,7 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
|
||||
@INotificationService private readonly _notificationService: INotificationService,
|
||||
@IElectronService private readonly _electronService: IElectronService,
|
||||
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
|
||||
@IWorkbenchEnvironmentService private readonly _environmentService: IWorkbenchEnvironmentService,
|
||||
@IWorkbenchEnvironmentService private readonly _environmentService: INativeWorkbenchEnvironmentService,
|
||||
@ITelemetryService private readonly _telemetryService: ITelemetryService,
|
||||
@ILogService private readonly _logService: ILogService,
|
||||
@ILabelService private readonly _labelService: ILabelService,
|
||||
|
||||
@@ -35,7 +35,7 @@ import { Logger } from 'vs/workbench/services/extensions/common/extensionPoints'
|
||||
import { flatten } from 'vs/base/common/arrays';
|
||||
import { IStaticExtensionsService } from 'vs/workbench/services/extensions/common/staticExtensions';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
|
||||
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { IRemoteExplorerService } from 'vs/workbench/services/remote/common/remoteExplorerService';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
@@ -60,7 +60,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
|
||||
constructor(
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
|
||||
@IWorkbenchEnvironmentService protected readonly _environmentService: INativeWorkbenchEnvironmentService,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IWorkbenchExtensionEnablementService extensionEnablementService: IWorkbenchExtensionEnablementService,
|
||||
@IFileService fileService: IFileService,
|
||||
@@ -73,14 +73,13 @@ export class ExtensionService extends AbstractExtensionService implements IExten
|
||||
@IStaticExtensionsService private readonly _staticExtensions: IStaticExtensionsService,
|
||||
@IElectronService private readonly _electronService: IElectronService,
|
||||
@IHostService private readonly _hostService: IHostService,
|
||||
@IElectronEnvironmentService private readonly _electronEnvironmentService: IElectronEnvironmentService,
|
||||
@IRemoteExplorerService private readonly _remoteExplorerService: IRemoteExplorerService,
|
||||
@IExtensionGalleryService private readonly _extensionGalleryService: IExtensionGalleryService,
|
||||
) {
|
||||
super(
|
||||
instantiationService,
|
||||
notificationService,
|
||||
environmentService,
|
||||
_environmentService,
|
||||
telemetryService,
|
||||
extensionEnablementService,
|
||||
fileService,
|
||||
@@ -366,7 +365,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
|
||||
|
||||
const result: ExtensionHostProcessManager[] = [];
|
||||
|
||||
const extHostProcessWorker = this._instantiationService.createInstance(ExtensionHostProcessWorker, autoStart, extensions, this._electronEnvironmentService.extHostLogsPath);
|
||||
const extHostProcessWorker = this._instantiationService.createInstance(ExtensionHostProcessWorker, autoStart, extensions, this._environmentService.extHostLogsPath);
|
||||
const extHostProcessManager = this._instantiationService.createInstance(ExtensionHostProcessManager, true, extHostProcessWorker, null, initialActivationEvents);
|
||||
result.push(extHostProcessManager);
|
||||
|
||||
@@ -464,16 +463,13 @@ export class ExtensionService extends AbstractExtensionService implements IExten
|
||||
} catch (err) {
|
||||
const remoteName = getRemoteName(remoteAuthority);
|
||||
if (RemoteAuthorityResolverError.isNoResolverFound(err)) {
|
||||
this._handleNoResolverFound(remoteName, allExtensions);
|
||||
err.isHandled = await this._handleNoResolverFound(remoteName, allExtensions);
|
||||
} else {
|
||||
console.log(err);
|
||||
if (RemoteAuthorityResolverError.isHandledNotAvailable(err)) {
|
||||
console.log(`Not showing a notification for the error`);
|
||||
} else {
|
||||
this._notificationService.notify({ severity: Severity.Error, message: nls.localize('resolveAuthorityFailure', "Resolving the authority `{0}` failed", remoteName) });
|
||||
if (RemoteAuthorityResolverError.isHandled(err)) {
|
||||
console.log(`Error handled: Not showing a notification for the error`);
|
||||
}
|
||||
}
|
||||
|
||||
this._remoteAuthorityResolverService.setResolvedAuthorityError(remoteAuthority, err);
|
||||
|
||||
// Proceed with the local extension host
|
||||
@@ -589,10 +585,10 @@ export class ExtensionService extends AbstractExtensionService implements IExten
|
||||
}
|
||||
}
|
||||
|
||||
private async _handleNoResolverFound(remoteName: string, allExtensions: IExtensionDescription[]): Promise<void> {
|
||||
private async _handleNoResolverFound(remoteName: string, allExtensions: IExtensionDescription[]): Promise<boolean> {
|
||||
const recommendation = this._productService.remoteExtensionTips?.[remoteName];
|
||||
if (!recommendation) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
const sendTelemetry = (userReaction: 'install' | 'enable' | 'cancel') => {
|
||||
/* __GDPR__
|
||||
@@ -608,7 +604,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
|
||||
const extension = allExtensions.filter(e => e.identifier.value === resolverExtensionId)[0];
|
||||
if (extension) {
|
||||
if (this._isDisabled(extension)) {
|
||||
const message = nls.localize('enableResolver', "Extension '{0}' is required to open the remote window.\nOk to enable?", recommendation.friendlyName);
|
||||
const message = nls.localize('enableResolver', "Extension '{0}' is required to open the remote window.\nOK to enable?", recommendation.friendlyName);
|
||||
this._notificationService.prompt(Severity.Info, message,
|
||||
[{
|
||||
label: nls.localize('enable', 'Enable and Reload'),
|
||||
@@ -623,7 +619,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
|
||||
}
|
||||
} else {
|
||||
// Install the Extension and reload the window to handle.
|
||||
const message = nls.localize('installResolver', "Extension '{0}' is required to open the remote window.\nOk to install?", recommendation.friendlyName);
|
||||
const message = nls.localize('installResolver', "Extension '{0}' is required to open the remote window.\nnOK to install?", recommendation.friendlyName);
|
||||
this._notificationService.prompt(Severity.Info, message,
|
||||
[{
|
||||
label: nls.localize('install', 'Install and Reload'),
|
||||
@@ -646,6 +642,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
|
||||
);
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,4 +212,13 @@ suite('RPCProtocol', () => {
|
||||
assert.equal(res, 7);
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #81424: SerializeRequest should throw if an argument can not be serialized', () => {
|
||||
let badObject = {};
|
||||
(<any>badObject).loop = badObject;
|
||||
|
||||
assert.throws(() => {
|
||||
bProxy.$m(badObject, '2');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user