From 101c2a01f1ccbf5ff8a3367496cb70a1a3d2f489 Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 1 Apr 2021 10:57:51 -0500 Subject: [PATCH] Fix tsc watch restarting when it shouldn't It seems reaching into lib/vscode for the types caused tsc to establish watches that caused it to restart over and over while vscode was building. The strategy used here is to symlink it instead which is the same thing we do for the proxy agent. --- lib/vscode/src/vs/ipc.d.ts | 1 + lib/vscode/src/vs/server/browser/client.ts | 2 +- lib/vscode/src/vs/server/entry.ts | 4 +- lib/vscode/src/vs/server/ipc.d.ts | 132 -------------------- lib/vscode/src/vs/server/node/server.ts | 6 +- src/node/cli.ts | 2 +- src/node/entry.ts | 2 +- src/node/vscode.ts | 2 +- typings/ipc.d.ts | 135 +++++++++++++++++++++ 9 files changed, 145 insertions(+), 141 deletions(-) create mode 120000 lib/vscode/src/vs/ipc.d.ts delete mode 100644 lib/vscode/src/vs/server/ipc.d.ts create mode 100644 typings/ipc.d.ts diff --git a/lib/vscode/src/vs/ipc.d.ts b/lib/vscode/src/vs/ipc.d.ts new file mode 120000 index 00000000..dff4f400 --- /dev/null +++ b/lib/vscode/src/vs/ipc.d.ts @@ -0,0 +1 @@ +../../../../typings/ipc.d.ts \ No newline at end of file diff --git a/lib/vscode/src/vs/server/browser/client.ts b/lib/vscode/src/vs/server/browser/client.ts index d7e3d543..ebd939bc 100644 --- a/lib/vscode/src/vs/server/browser/client.ts +++ b/lib/vscode/src/vs/server/browser/client.ts @@ -1,5 +1,6 @@ import * as path from 'vs/base/common/path'; import { URI } from 'vs/base/common/uri'; +import { Options } from 'vs/ipc'; import { localize } from 'vs/nls'; import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; @@ -11,7 +12,6 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { TelemetryChannelClient } from 'vs/server/common/telemetry'; -import { Options } from 'vs/server/ipc.d'; import 'vs/workbench/contrib/localizations/browser/localizations.contribution'; import { LocalizationsService } from 'vs/workbench/services/localizations/electron-sandbox/localizationsService'; import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; diff --git a/lib/vscode/src/vs/server/entry.ts b/lib/vscode/src/vs/server/entry.ts index 89a872d4..901bcda6 100644 --- a/lib/vscode/src/vs/server/entry.ts +++ b/lib/vscode/src/vs/server/entry.ts @@ -1,10 +1,10 @@ import { field } from '@coder/logger'; import { setUnexpectedErrorHandler } from 'vs/base/common/errors'; -import { CodeServerMessage, VscodeMessage } from 'vs/server/ipc'; +import * as proxyAgent from 'vs/base/node/proxy_agent'; +import { CodeServerMessage, VscodeMessage } from 'vs/ipc'; import { logger } from 'vs/server/node/logger'; import { enableCustomMarketplace } from 'vs/server/node/marketplace'; import { Vscode } from 'vs/server/node/server'; -import * as proxyAgent from 'vs/base/node/proxy_agent'; setUnexpectedErrorHandler((error) => logger.warn(error instanceof Error ? error.message : error)); enableCustomMarketplace(); diff --git a/lib/vscode/src/vs/server/ipc.d.ts b/lib/vscode/src/vs/server/ipc.d.ts deleted file mode 100644 index 613d1e0e..00000000 --- a/lib/vscode/src/vs/server/ipc.d.ts +++ /dev/null @@ -1,132 +0,0 @@ -/** - * External interfaces for integration into code-server over IPC. No vs imports - * should be made in this file. - */ -export interface Options { - base: string - disableTelemetry: boolean - disableUpdateCheck: boolean -} - -export interface InitMessage { - type: "init" - id: string - options: VscodeOptions -} - -export type Query = { [key: string]: string | string[] | undefined | Query | Query[] } - -export interface SocketMessage { - type: "socket" - query: Query - permessageDeflate: boolean -} - -export interface CliMessage { - type: "cli" - args: Args -} - -export interface OpenCommandPipeArgs { - type: "open" - fileURIs?: string[] - folderURIs: string[] - forceNewWindow?: boolean - diffMode?: boolean - addMode?: boolean - gotoLineMode?: boolean - forceReuseWindow?: boolean - waitMarkerFilePath?: string -} - -export type CodeServerMessage = InitMessage | SocketMessage | CliMessage - -export interface ReadyMessage { - type: "ready" -} - -export interface OptionsMessage { - id: string - type: "options" - options: WorkbenchOptions -} - -export type VscodeMessage = ReadyMessage | OptionsMessage - -export interface StartPath { - url: string - workspace: boolean -} - -export interface Args { - "user-data-dir"?: string - - "enable-proposed-api"?: string[] - "extensions-dir"?: string - "builtin-extensions-dir"?: string - "extra-extensions-dir"?: string[] - "extra-builtin-extensions-dir"?: string[] - "ignore-last-opened"?: boolean - - locale?: string - - log?: string - verbose?: boolean - - _: string[] -} - -export interface VscodeOptions { - readonly args: Args - readonly remoteAuthority: string - readonly startPath?: StartPath -} - -export interface VscodeOptionsMessage extends VscodeOptions { - readonly id: string -} - -export interface UriComponents { - readonly scheme: string - readonly authority: string - readonly path: string - readonly query: string - readonly fragment: string -} - -export interface NLSConfiguration { - locale: string - availableLanguages: { - [key: string]: string - } - pseudo?: boolean - _languagePackSupport?: boolean -} - -export interface WorkbenchOptions { - readonly workbenchWebConfiguration: { - readonly remoteAuthority?: string - readonly folderUri?: UriComponents - readonly workspaceUri?: UriComponents - readonly logLevel?: number - readonly workspaceProvider?: { - payload: [["userDataPath", string], ["enableProposedApi", string]] - } - } - readonly remoteUserDataUri: UriComponents - readonly productConfiguration: { - codeServerVersion?: string - readonly extensionsGallery?: { - readonly serviceUrl: string - readonly itemUrl: string - readonly controlUrl: string - readonly recommendationsUrl: string - } - } - readonly nlsConfiguration: NLSConfiguration - readonly commit: string -} - -export interface WorkbenchOptionsMessage { - id: string -} diff --git a/lib/vscode/src/vs/server/node/server.ts b/lib/vscode/src/vs/server/node/server.ts index 1626373e..3c99d415 100644 --- a/lib/vscode/src/vs/server/node/server.ts +++ b/lib/vscode/src/vs/server/node/server.ts @@ -1,7 +1,7 @@ import { field } from '@coder/logger'; -import { release } from 'os'; import * as fs from 'fs'; import * as net from 'net'; +import { release } from 'os'; import * as path from 'path'; import { Emitter } from 'vs/base/common/event'; import { Schemas } from 'vs/base/common/network'; @@ -10,6 +10,7 @@ import { getMachineId } from 'vs/base/node/id'; import { ClientConnectionEvent, IPCServer, IServerChannel, ProxyChannel } from 'vs/base/parts/ipc/common/ipc'; import { LogsDataCleaner } from 'vs/code/electron-browser/sharedProcess/contrib/logsDataCleaner'; import { main } from 'vs/code/node/cliProcessMain'; +import { Query, VscodeOptions, WorkbenchOptions } from 'vs/ipc'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ConfigurationService } from 'vs/platform/configuration/common/configurationService'; import { ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc'; @@ -40,14 +41,13 @@ import { IRequestService } from 'vs/platform/request/common/request'; import { RequestChannel } from 'vs/platform/request/common/requestIpc'; import { RequestService } from 'vs/platform/request/node/requestService'; import ErrorTelemetry from 'vs/platform/telemetry/browser/errorTelemetry'; +import { resolveCommonProperties } from 'vs/platform/telemetry/common/commonProperties'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { TelemetryLogAppender } from 'vs/platform/telemetry/common/telemetryLogAppender'; import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService'; import { combinedAppender, NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender'; -import { resolveCommonProperties } from 'vs/platform/telemetry/common/commonProperties'; import { TelemetryChannel } from 'vs/server/common/telemetry'; -import { Query, VscodeOptions, WorkbenchOptions } from 'vs/server/ipc'; import { ExtensionEnvironmentChannel, FileProviderChannel, TerminalProviderChannel } from 'vs/server/node/channel'; import { Connection, ExtensionHostConnection, ManagementConnection } from 'vs/server/node/connection'; import { TelemetryClient } from 'vs/server/node/insights'; diff --git a/src/node/cli.ts b/src/node/cli.ts index 09542f0b..461a2e18 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -3,7 +3,7 @@ import { promises as fs } from "fs" import yaml from "js-yaml" import * as os from "os" import * as path from "path" -import { Args as VsArgs } from "../../lib/vscode/src/vs/server/ipc" +import { Args as VsArgs } from "../../typings/ipc" import { canConnect, generateCertificate, generatePassword, humanPath, paths } from "./util" export enum AuthType { diff --git a/src/node/entry.ts b/src/node/entry.ts index 2f569b4e..b7b61b8f 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -2,7 +2,7 @@ import { field, logger } from "@coder/logger" import * as cp from "child_process" import http from "http" import * as path from "path" -import { CliMessage, OpenCommandPipeArgs } from "../../lib/vscode/src/vs/server/ipc" +import { CliMessage, OpenCommandPipeArgs } from "../../typings/ipc" import { plural } from "../common/util" import { createApp, ensureAddress } from "./app" import { diff --git a/src/node/vscode.ts b/src/node/vscode.ts index 44b46ec7..a69253fb 100644 --- a/src/node/vscode.ts +++ b/src/node/vscode.ts @@ -2,7 +2,7 @@ import { logger } from "@coder/logger" import * as cp from "child_process" import * as net from "net" import * as path from "path" -import * as ipc from "../../lib/vscode/src/vs/server/ipc" +import * as ipc from "../../typings/ipc" import { arrayify, generateUuid } from "../common/util" import { rootPath } from "./constants" import { settings } from "./settings" diff --git a/typings/ipc.d.ts b/typings/ipc.d.ts new file mode 100644 index 00000000..f31e1d45 --- /dev/null +++ b/typings/ipc.d.ts @@ -0,0 +1,135 @@ +/** + * External interfaces for integration into code-server over IPC. + * This file exists in two locations: + * - typings/ipc.d.ts + * - lib/vscode/src/typings/ipc.d.ts + * The second is a symlink to the first. + */ +export interface Options { + base: string + disableTelemetry: boolean + disableUpdateCheck: boolean +} + +export interface InitMessage { + type: "init" + id: string + options: VscodeOptions +} + +export type Query = { [key: string]: string | string[] | undefined | Query | Query[] } + +export interface SocketMessage { + type: "socket" + query: Query + permessageDeflate: boolean +} + +export interface CliMessage { + type: "cli" + args: Args +} + +export interface OpenCommandPipeArgs { + type: "open" + fileURIs?: string[] + folderURIs: string[] + forceNewWindow?: boolean + diffMode?: boolean + addMode?: boolean + gotoLineMode?: boolean + forceReuseWindow?: boolean + waitMarkerFilePath?: string +} + +export type CodeServerMessage = InitMessage | SocketMessage | CliMessage + +export interface ReadyMessage { + type: "ready" +} + +export interface OptionsMessage { + id: string + type: "options" + options: WorkbenchOptions +} + +export type VscodeMessage = ReadyMessage | OptionsMessage + +export interface StartPath { + url: string + workspace: boolean +} + +export interface Args { + "user-data-dir"?: string + + "enable-proposed-api"?: string[] + "extensions-dir"?: string + "builtin-extensions-dir"?: string + "extra-extensions-dir"?: string[] + "extra-builtin-extensions-dir"?: string[] + "ignore-last-opened"?: boolean + + locale?: string + + log?: string + verbose?: boolean + + _: string[] +} + +export interface VscodeOptions { + readonly args: Args + readonly remoteAuthority: string + readonly startPath?: StartPath +} + +export interface VscodeOptionsMessage extends VscodeOptions { + readonly id: string +} + +export interface UriComponents { + readonly scheme: string + readonly authority: string + readonly path: string + readonly query: string + readonly fragment: string +} + +export interface NLSConfiguration { + locale: string + availableLanguages: { + [key: string]: string + } + pseudo?: boolean + _languagePackSupport?: boolean +} + +export interface WorkbenchOptions { + readonly workbenchWebConfiguration: { + readonly remoteAuthority?: string + readonly folderUri?: UriComponents + readonly workspaceUri?: UriComponents + readonly logLevel?: number + readonly workspaceProvider?: { + payload: [["userDataPath", string], ["enableProposedApi", string]] + } + } + readonly remoteUserDataUri: UriComponents + readonly productConfiguration: { + codeServerVersion?: string + readonly extensionsGallery?: { + readonly serviceUrl: string + readonly itemUrl: string + readonly controlUrl: string + readonly recommendationsUrl: string + } + } + readonly nlsConfiguration: NLSConfiguration + readonly commit: string +} + +export interface WorkbenchOptionsMessage { + id: string +}