Skip to content

Commit 2a08ee5

Browse files
committed
Remove compilation check
If you do a regular non-watch build there are no compilation stats so this bricks VS Code in CI when running the unit tests. I am not sure how best to fix this for the case where you have a build that has not been packaged yet so I just removed it for now and added a message to check if VS Code is compiling when in dev mode.
1 parent 601f57a commit 2a08ee5

File tree

3 files changed

+10
-64
lines changed

3 files changed

+10
-64
lines changed

ci/dev/watch.ts

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { spawn, fork, ChildProcess } from "child_process"
2-
import { promises as fs } from "fs"
32
import * as path from "path"
4-
import { CompilationStats, onLine, OnLineCallback } from "../../src/node/util"
3+
import { onLine, OnLineCallback } from "../../src/node/util"
54

65
interface DevelopmentCompilers {
76
[key: string]: ChildProcess | undefined
@@ -16,7 +15,6 @@ class Watcher {
1615
private readonly paths = {
1716
/** Path to uncompiled VS Code source. */
1817
vscodeDir: path.join(this.rootPath, "vendor", "modules", "code-oss-dev"),
19-
compilationStatsFile: path.join(this.rootPath, "out", "watcher.json"),
2018
pluginDir: process.env.PLUGIN_DIR,
2119
}
2220

@@ -88,7 +86,6 @@ class Watcher {
8886

8987
if (strippedLine.includes("Finished compilation with")) {
9088
console.log("[VS Code] ✨ Finished compiling! ✨", "(Refresh your web browser ♻️)")
91-
this.emitCompilationStats()
9289
this.reloadWebServer()
9390
}
9491
}
@@ -118,19 +115,6 @@ class Watcher {
118115

119116
//#region Utilities
120117

121-
/**
122-
* Emits a file containing compilation data.
123-
* This is especially useful when Express needs to determine if VS Code is still compiling.
124-
*/
125-
private emitCompilationStats(): Promise<void> {
126-
const stats: CompilationStats = {
127-
lastCompiledAt: new Date(),
128-
}
129-
130-
console.log("Writing watcher stats...")
131-
return fs.writeFile(this.paths.compilationStatsFile, JSON.stringify(stats, null, 2))
132-
}
133-
134118
private dispose(code: number | null): void {
135119
for (const [processName, devProcess] of Object.entries(this.compilers)) {
136120
console.log(`[${processName}]`, "Killing...\n")

src/node/routes/vscode.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { logError } from "../../common/util"
55
import { toVsCodeArgs } from "../cli"
66
import { isDevMode } from "../constants"
77
import { authenticated, ensureAuthenticated, redirect, self } from "../http"
8-
import { loadAMDModule, readCompilationStats } from "../util"
8+
import { loadAMDModule } from "../util"
99
import { Router as WsRouter } from "../wsRouter"
1010
import { errorHandler } from "./errors"
1111

@@ -93,15 +93,6 @@ export class CodeServerRouteWrapper {
9393
return next()
9494
}
9595

96-
if (isDevMode) {
97-
// Is the development mode file watcher still busy?
98-
const compileStats = await readCompilationStats()
99-
100-
if (!compileStats || !compileStats.lastCompiledAt) {
101-
return next(new Error("VS Code may still be compiling..."))
102-
}
103-
}
104-
10596
// Create the server...
10697

10798
const { args } = req
@@ -116,9 +107,12 @@ export class CodeServerRouteWrapper {
116107

117108
try {
118109
this._codeServerMain = await createVSServer(null, await toVsCodeArgs(args))
119-
} catch (createServerError) {
120-
logError(logger, "CodeServerRouteWrapper", createServerError)
121-
return next(createServerError)
110+
} catch (error) {
111+
logError(logger, "CodeServerRouteWrapper", error)
112+
if (isDevMode) {
113+
return next(new Error((error instanceof Error ? error.message : error) + " (VS Code may still be compiling)"))
114+
}
115+
return next(error)
122116
}
123117

124118
return next()

src/node/util.ts

+2-34
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ import * as argon2 from "argon2"
33
import * as cp from "child_process"
44
import * as crypto from "crypto"
55
import envPaths from "env-paths"
6-
import { promises as fs, Stats } from "fs"
6+
import { promises as fs } from "fs"
77
import * as net from "net"
88
import * as os from "os"
99
import * as path from "path"
1010
import safeCompare from "safe-compare"
1111
import * as util from "util"
1212
import xdgBasedir from "xdg-basedir"
13-
import { logError } from "../common/util"
14-
import { isDevMode, rootPath, vsRootPath } from "./constants"
13+
import { vsRootPath } from "./constants"
1514

1615
export interface Paths {
1716
data: string
@@ -523,34 +522,3 @@ export const loadAMDModule = async <T>(amdPath: string, exportName: string): Pro
523522

524523
return module[exportName] as T
525524
}
526-
527-
export interface CompilationStats {
528-
lastCompiledAt: Date
529-
}
530-
531-
export const readCompilationStats = async (): Promise<null | CompilationStats> => {
532-
if (!isDevMode) {
533-
throw new Error("Compilation stats are only present in development")
534-
}
535-
536-
const filePath = path.join(rootPath, "out/watcher.json")
537-
let stat: Stats
538-
try {
539-
stat = await fs.stat(filePath)
540-
} catch (error) {
541-
return null
542-
}
543-
544-
if (!stat.isFile()) {
545-
return null
546-
}
547-
548-
try {
549-
const file = await fs.readFile(filePath)
550-
return JSON.parse(file.toString("utf-8"))
551-
} catch (error) {
552-
logError(logger, "VS Code", error)
553-
}
554-
555-
return null
556-
}

0 commit comments

Comments
 (0)