Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable VS Code file watching for yarn pnp #213238

Merged
merged 1 commit into from
May 22, 2024
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
4 changes: 4 additions & 0 deletions extensions/typescript-language-features/src/tsServer/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ export class API {
public lt(other: API): boolean {
return !this.gte(other);
}

public isYarnPnp(): boolean {
return this.fullVersionString.includes('-sdk');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ export class TypeScriptServerSpawner {

args.push('--noGetErrOnBackgroundUpdate');

if (apiVersion.gte(API.v544) && configuration.useVsCodeWatcher) {
if (
apiVersion.gte(API.v544)
&& configuration.useVsCodeWatcher
&& !apiVersion.isYarnPnp() // Disable for yarn pnp as it currently breaks with the VS Code watcher
) {
args.push('--canUseWatchEvents');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@

import * as path from 'path';
import * as vscode from 'vscode';
import { ServiceConfigurationProvider, SyntaxServerConfiguration, TsServerLogLevel, TypeScriptServiceConfiguration, areServiceConfigurationsEqual } from './configuration/configuration';
import * as fileSchemes from './configuration/fileSchemes';
import { Schemes } from './configuration/schemes';
import { IExperimentationTelemetryReporter } from './experimentTelemetryReporter';
import { DiagnosticKind, DiagnosticsManager } from './languageFeatures/diagnostics';
import * as Proto from './tsServer/protocol/protocol';
import { EventName } from './tsServer/protocol/protocol.const';
import { Logger } from './logging/logger';
import { TelemetryProperties, TelemetryReporter, VSCodeTelemetryReporter } from './logging/telemetry';
import Tracer from './logging/tracer';
import { ProjectType, inferredProjectCompilerOptions } from './tsconfig';
import { API } from './tsServer/api';
import BufferSyncSupport from './tsServer/bufferSyncSupport';
import { OngoingRequestCancellerFactory } from './tsServer/cancellation';
import { ILogDirectoryProvider } from './tsServer/logDirectoryProvider';
import { NodeVersionManager } from './tsServer/nodeManager';
import { TypeScriptPluginPathsProvider } from './tsServer/pluginPathsProvider';
import { PluginManager, TypeScriptServerPlugin } from './tsServer/plugins';
import * as Proto from './tsServer/protocol/protocol';
import { EventName } from './tsServer/protocol/protocol.const';
import { ITypeScriptServer, TsServerLog, TsServerProcessFactory, TypeScriptServerExitEvent } from './tsServer/server';
import { TypeScriptServerError } from './tsServer/serverError';
import { TypeScriptServerSpawner } from './tsServer/spawner';
import { TypeScriptVersionManager } from './tsServer/versionManager';
import { ITypeScriptVersionProvider, TypeScriptVersion } from './tsServer/versionProvider';
import { ClientCapabilities, ClientCapability, ExecConfig, ITypeScriptServiceClient, ServerResponse, TypeScriptRequests } from './typescriptService';
import { ServiceConfigurationProvider, SyntaxServerConfiguration, TsServerLogLevel, TypeScriptServiceConfiguration, areServiceConfigurationsEqual } from './configuration/configuration';
import { Disposable, DisposableStore, disposeAll } from './utils/dispose';
import * as fileSchemes from './configuration/fileSchemes';
import { Logger } from './logging/logger';
import { isWeb, isWebAndHasSharedArrayBuffers } from './utils/platform';
import { PluginManager, TypeScriptServerPlugin } from './tsServer/plugins';
import { TelemetryProperties, TelemetryReporter, VSCodeTelemetryReporter } from './logging/telemetry';
import Tracer from './logging/tracer';
import { ProjectType, inferredProjectCompilerOptions } from './tsconfig';
import { Schemes } from './configuration/schemes';
import { NodeVersionManager } from './tsServer/nodeManager';


export interface TsDiagnostics {
Expand Down Expand Up @@ -463,7 +463,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}
*/
this.logTelemetry('tsserver.error');
this.serviceExited(false);
this.serviceExited(false, apiVersion);
});

handle.onExit((data: TypeScriptServerExitEvent) => {
Expand All @@ -484,7 +484,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
*/
this.logTelemetry('tsserver.exitWithCode', { code: code ?? undefined, signal: signal ?? undefined });


if (this.token !== mytoken) {
// this is coming from an old process
return;
Expand All @@ -493,7 +492,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
if (handle.tsServerLog?.type === 'file') {
this.info(`TSServer log file: ${handle.tsServerLog.uri.fsPath}`);
}
this.serviceExited(!this.isRestarting);
this.serviceExited(!this.isRestarting, apiVersion);
this.isRestarting = false;
});

Expand Down Expand Up @@ -612,7 +611,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
};
}

private serviceExited(restart: boolean): void {
private serviceExited(restart: boolean, tsVersion: API): void {
this.resetWatchers();
this.loadingIndicator.reset();

Expand Down Expand Up @@ -686,25 +685,42 @@ export default class TypeScriptServiceClient extends Disposable implements IType
this._isPromptingAfterCrash = true;
}

prompt?.then(item => {
prompt?.then(async item => {
this._isPromptingAfterCrash = false;

if (item === reportIssueItem) {

const minModernTsVersion = this.versionProvider.bundledVersion.apiVersion;

if (
// Don't allow reporting issues using the PnP patched version of TS Server
if (tsVersion.isYarnPnp()) {
const reportIssue: vscode.MessageItem = {
title: vscode.l10n.t("Report issue against Yarn PnP"),
};
const response = await vscode.window.showWarningMessage(
vscode.l10n.t("Please report an issue against Yarn PnP"),
{
modal: true,
detail: vscode.l10n.t("The workspace is using a version of the TypeScript Server that has been patched by Yarn PnP. This patching is a common source of bugs."),
},
reportIssue);

if (response === reportIssue) {
vscode.env.openExternal(vscode.Uri.parse('https://github.com/yarnpkg/berry/issues'));
}
}
// Don't allow reporting issues with old TS versions
else if (
minModernTsVersion &&
previousState.type === ServerState.Type.Errored &&
previousState.error instanceof TypeScriptServerError &&
previousState.error.version.apiVersion?.lt(minModernTsVersion)
tsVersion.lt(minModernTsVersion)
) {
vscode.window.showWarningMessage(
vscode.l10n.t("Please update your TypeScript version"),
{
modal: true,
detail: vscode.l10n.t(
"The workspace is using an old version of TypeScript ({0}).\n\nBefore reporting an issue, please update the workspace to use TypeScript {1} or newer to make sure the bug has not already been fixed.",
previousState.error.version.apiVersion.displayName,
tsVersion.displayName,
minModernTsVersion.displayName),
});
} else {
Expand Down
Loading