Skip to content

Commit 61b749a

Browse files
Armando AguirreArmando Aguirre Sepulveda
andauthored
Refactored old server errors (#165)
* Refactored old server errors * Fixed missing rawError file * Added old server version to title and description * Updated test snapshot * Fixed snapshot typos * whats wrong with me!? Fixed more typos --------- Co-authored-by: Armando Aguirre Sepulveda <[email protected]>
1 parent 9e0ad34 commit 61b749a

File tree

4 files changed

+320
-25
lines changed

4 files changed

+320
-25
lines changed

src/main.ts

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ async function getTsServerRepoResult(
310310
? prettyPrintServerHarnessOutput(oldSpawnResult.stdout, /*filter*/ false)
311311
: `Timed out after ${executionTimeout} ms`));
312312

313+
await fs.promises.writeFile(rawErrorPath, oldSpawnResult?.stdout ?? `Timed out after ${executionTimeout} ms`);
314+
313315
// We don't want to drown PRs with comments.
314316
// Override the results to say nothing interesting changed.
315317
if (isPr && newServerFailed && oldSpawnResult) {
@@ -335,10 +337,7 @@ async function getTsServerRepoResult(
335337
installCommands,
336338
};
337339

338-
if (oldServerFailed && !newServerFailed) {
339-
return { status: "Detected interesting changes", tsServerResult }
340-
}
341-
if (!newServerFailed) {
340+
if (!oldServerFailed && !newServerFailed) {
342341
return { status: "Detected no interesting changes" };
343342
}
344343

@@ -404,25 +403,77 @@ function createOldErrorSummary(summaries: Summary[]): string {
404403

405404
let text = `
406405
<details>
407-
<summary>${errorMessage}</summary>
406+
<summary>New server no longer reports this error: ${errorMessage}</summary>
408407
409408
\`\`\`
410409
${oldServerError}
411410
\`\`\`
412411
413-
<h4>Repos no longer reporting the error</h4>
414-
<ul>
415-
`;
412+
<h4>Affected repos</h4>`;
416413

417414
for (const summary of summaries) {
418415
const owner = summary.repo.owner ? `${mdEscape(summary.repo.owner)}/` : "";
419416
const url = summary.repo.url ?? "";
420417

421-
text += `<li><a href="${url}">${owner + mdEscape(summary.repo.name)}</a></li>\n`
418+
text += `
419+
<details>
420+
<summary><a href="${url}">${owner + mdEscape(summary.repo.name)}</a></summary>
421+
Raw error text: <code>${summary.rawErrorArtifactPath}</code> in the <a href="${artifactFolderUrlPlaceholder}">artifact folder</a> <br />
422+
Replay commands: <code>${summary.replayScriptArtifactPath}</code> in the <a href="${artifactFolderUrlPlaceholder}">artifact folder</a>
423+
<h4>Last few requests</h4>
424+
425+
\`\`\`json
426+
${summary.replayScript}
427+
\`\`\`
428+
429+
<h4>Repro steps</h4>
430+
431+
\`\`\`bash
432+
#!/bin/bash
433+
434+
`;
435+
// No url means is user test repo
436+
if (!summary.repo.url) {
437+
text += `# Manually download user test \`${summary.repo.name}\`\n`;
438+
}
439+
else {
440+
text += `git clone ${summary.repo.url} --recurse-submodules\n`;
441+
442+
if (summary.commit) {
443+
text += `git -C "./${summary.repo.name}" reset --hard ${summary.commit}\n`;
444+
}
445+
}
446+
447+
if (summary.tsServerResult.installCommands.length > 1) {
448+
text += "# Install packages (exact steps are below, but it might be easier to follow the repo readme)\n";
449+
}
450+
for (const command of summary.tsServerResult.installCommands) {
451+
const workingDirFlag = command.tool === ip.InstallTool.Npm
452+
? "--prefix"
453+
: command.tool === ip.InstallTool.Yarn
454+
? "--cwd"
455+
: "--dir"; // pnpm
456+
457+
text += `${command.tool} ${workingDirFlag} "./${command.prettyDirectory}" ${command.arguments.join(" ")}\n`;
458+
}
459+
460+
text += `downloadUrl=$(curl -s "${getArtifactsApiUrlPlaceholder}?artifactName=${summary.resultDirName}&api-version=7.0" | jq -r ".resource.downloadUrl")
461+
wget -O ${summary.resultDirName}.zip "$downloadUrl"
462+
unzip -p ${summary.resultDirName}.zip ${summary.resultDirName}/${summary.replayScriptName} > ${summary.replayScriptName}
463+
npm install --no-save @typescript/server-replay
464+
\`\`\`
465+
466+
To run the repro:
467+
\`\`\`bash
468+
# \`npx tsreplay --help\` to learn about helpful switches for debugging, logging, etc.
469+
npx tsreplay ./${summary.repo.name} ./${summary.replayScriptName} <PATH_TO_tsserver.js>
470+
\`\`\`
471+
472+
</details>
473+
`;
422474
}
423475

424476
text += `
425-
</ul>
426477
</details>
427478
`;
428479

src/postGithubIssue.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ for (const path of metadataFilePaths) {
4444
}
4545
}
4646

47-
const title = entrypoint === "tsserver"
48-
? `[ServerErrors][${language}] ${newTscResolvedVersion}`
49-
: `[NewErrors] ${newTscResolvedVersion} vs ${oldTscResolvedVersion}`;
47+
48+
const title = `${entrypoint === "tsserver" ? `[ServerErrors][${language}]` : `[NewErrors]`} ${newTscResolvedVersion} vs ${oldTscResolvedVersion}`;
5049

5150
const description = entrypoint === "tsserver"
52-
? `The following errors were reported by ${newTscResolvedVersion}`
51+
? `The following errors were reported by ${newTscResolvedVersion} vs ${oldTscResolvedVersion}`
5352
: `The following errors were reported by ${newTscResolvedVersion}, but not by ${oldTscResolvedVersion}`;
5453
let header = `${description}
5554
[Pipeline that generated this bug](https://typescript.visualstudio.com/TypeScript/_build?definitionId=48)

test/__snapshots__/main.test.ts.snap

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,191 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`main outputs old server errors 1`] = `
4+
[MockFunction] {
5+
"calls": [
6+
[
7+
"<BASE_PATH>/ts_downloads/base/MockRepoOwner.MockRepoName.rawError.txt",
8+
"Req #123 - cursedCommand
9+
Some error. Could not do something.
10+
Maybe a Debug fail.
11+
at a (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:1:1)
12+
at b (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:2:2)
13+
at c (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:3:3)
14+
at d (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:4:4)
15+
at e (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:5:5)",
16+
],
17+
[
18+
"<BASE_PATH>/ts_downloads/base/MockRepoOwner.MockRepoName.rawError.txt",
19+
"{"request_seq":"123","command":"cursedCommand","message":"Some error. Could not do something. \\nMaybe a Debug fail.\\n at a (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:1:1)\\n at b (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:2:2)\\n at c (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:3:3)\\n at d (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:4:4)\\n at e (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:5:5)"}",
20+
],
21+
[
22+
"<BASE_PATH>/RepoResults123/718e48b799650d4b66e5d80ad6bac7b9.results.txt",
23+
"<h2>Maybe a Debug fail.</h2>
24+
25+
\`\`\`
26+
Req #123 - cursedCommand
27+
at a (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:1:1)
28+
at b (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:2:2)
29+
at c (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:3:3)
30+
at d (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:4:4)
31+
at e (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:5:5)
32+
\`\`\`
33+
34+
<h4>Affected repos</h4>
35+
<details>
36+
<summary><a href="https://github.com/MockRepoOwner/MockRepoName">MockRepoOwner/MockRepoName</a></summary>
37+
Raw error text: <code>RepoResults123/MockRepoOwner.MockRepoName.rawError.txt</code> in the <a href="PLACEHOLDER_ARTIFACT_FOLDER">artifact folder</a> <br />
38+
Replay commands: <code>RepoResults123/MockRepoOwner.MockRepoName.replay.txt</code> in the <a href="PLACEHOLDER_ARTIFACT_FOLDER">artifact folder</a>
39+
<h4>Last few requests</h4>
40+
41+
\`\`\`json
42+
{"rootDirPlaceholder":"@PROJECT_ROOT@","serverArgs":["--disableAutomaticTypingAcquisition"]}
43+
{"seq":1,"type":"request","command":"configure","arguments":{"preferences":{"disableLineTextInReferences":true,"includePackageJsonAutoImports":"auto","includeCompletionsForImportStatements":true,"includeCompletionsWithSnippetText":true,"includeAutomaticOptionalChainCompletions":true,"includeCompletionsWithInsertText":true,"includeCompletionsWithClassMemberSnippets":true,"allowIncompleteCompletions":true,"includeCompletionsForModuleExports":false},"watchOptions":{"excludeDirectories":["**/node_modules"]}}}
44+
{"seq":2,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":[],"openFiles":[{"file":"@PROJECT_ROOT@/sample_repoName.config.js","projectRootPath":"@PROJECT_ROOT@"}]}}
45+
{"seq":3,"type":"request","command":"cursedCommand","arguments":{"file":"@PROJECT_ROOT@/src/sampleTsFile.ts","line":1,"offset":1,"includeExternalModuleExports":false,"triggerKind":1}}
46+
\`\`\`
47+
48+
<h4>Repro steps</h4>
49+
50+
\`\`\`bash
51+
#!/bin/bash
52+
53+
git clone https://github.com/MockRepoOwner/MockRepoName --recurse-submodules
54+
git -C "./MockRepoName" reset --hard 57b462387e88aa7e363af0daf867a5dc1e83a935
55+
# Install packages (exact steps are below, but it might be easier to follow the repo readme)
56+
npm --prefix "./dirA" install --prefer-offline --no-audit --no-progress --legacy-peer-deps --ignore-scripts -q
57+
npm --prefix "./dirB/dirC" install --prefer-offline --no-audit --no-progress --legacy-peer-deps --ignore-scripts -q
58+
npm --prefix "./dirD/dirE/dirF" install --prefer-offline --no-audit --no-progress --legacy-peer-deps --ignore-scripts -q
59+
downloadUrl=$(curl -s "PLACEHOLDER_GETARTIFACTS_API?artifactName=RepoResults123&api-version=7.0" | jq -r ".resource.downloadUrl")
60+
wget -O RepoResults123.zip "$downloadUrl"
61+
unzip -p RepoResults123.zip RepoResults123/MockRepoOwner.MockRepoName.replay.txt > MockRepoOwner.MockRepoName.replay.txt
62+
npm install --no-save @typescript/server-replay
63+
\`\`\`
64+
65+
To run the repro:
66+
\`\`\`bash
67+
# \`npx tsreplay --help\` to learn about helpful switches for debugging, logging, etc.
68+
npx tsreplay ./MockRepoName ./MockRepoOwner.MockRepoName.replay.txt <PATH_TO_tsserver.js>
69+
\`\`\`
70+
71+
</details>
72+
",
73+
{
74+
"encoding": "utf-8",
75+
},
76+
],
77+
[
78+
"<BASE_PATH>/RepoResults123/metadata.json",
79+
"{"newTsResolvedVersion":"1.1.1","oldTsResolvedVersion":"0.0.0","statusCounts":{"Detected interesting changes":1}}",
80+
{
81+
"encoding": "utf-8",
82+
},
83+
],
84+
[
85+
"<BASE_PATH>/ts_downloads/base/MockRepoOwner.MockRepoName.rawError.txt",
86+
"{"request_seq":"123","command":"cursedCommand","message":"Some error. Could not do something. \\nMaybe a Debug fail.\\n at a (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:1:1)\\n at b (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:2:2)\\n at c (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:3:3)\\n at d (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:4:4)\\n at e (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:5:5)"}",
87+
],
88+
[
89+
"<BASE_PATH>/RepoResults123/!718e48b799650d4b66e5d80ad6bac7b9.results.txt",
90+
"
91+
<details>
92+
<summary>New server no longer reports this error: Maybe a Debug fail.</summary>
93+
94+
\`\`\`
95+
Req #123 - cursedCommand
96+
at a (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:1:1)
97+
at b (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:2:2)
98+
at c (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:3:3)
99+
at d (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:4:4)
100+
at e (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:5:5)
101+
\`\`\`
102+
103+
<h4>Affected repos</h4>
104+
<details>
105+
<summary><a href="https://github.com/MockRepoOwner/MockRepoName">MockRepoOwner/MockRepoName</a></summary>
106+
Raw error text: <code>RepoResults123/MockRepoOwner.MockRepoName.rawError.txt</code> in the <a href="PLACEHOLDER_ARTIFACT_FOLDER">artifact folder</a> <br />
107+
Replay commands: <code>RepoResults123/MockRepoOwner.MockRepoName.replay.txt</code> in the <a href="PLACEHOLDER_ARTIFACT_FOLDER">artifact folder</a>
108+
<h4>Last few requests</h4>
109+
110+
\`\`\`json
111+
{"rootDirPlaceholder":"@PROJECT_ROOT@","serverArgs":["--disableAutomaticTypingAcquisition"]}
112+
{"seq":1,"type":"request","command":"configure","arguments":{"preferences":{"disableLineTextInReferences":true,"includePackageJsonAutoImports":"auto","includeCompletionsForImportStatements":true,"includeCompletionsWithSnippetText":true,"includeAutomaticOptionalChainCompletions":true,"includeCompletionsWithInsertText":true,"includeCompletionsWithClassMemberSnippets":true,"allowIncompleteCompletions":true,"includeCompletionsForModuleExports":false},"watchOptions":{"excludeDirectories":["**/node_modules"]}}}
113+
{"seq":2,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":[],"openFiles":[{"file":"@PROJECT_ROOT@/sample_repoName.config.js","projectRootPath":"@PROJECT_ROOT@"}]}}
114+
{"seq":3,"type":"request","command":"cursedCommand","arguments":{"file":"@PROJECT_ROOT@/src/sampleTsFile.ts","line":1,"offset":1,"includeExternalModuleExports":false,"triggerKind":1}}
115+
\`\`\`
116+
117+
<h4>Repro steps</h4>
118+
119+
\`\`\`bash
120+
#!/bin/bash
121+
122+
git clone https://github.com/MockRepoOwner/MockRepoName --recurse-submodules
123+
git -C "./MockRepoName" reset --hard 57b462387e88aa7e363af0daf867a5dc1e83a935
124+
# Install packages (exact steps are below, but it might be easier to follow the repo readme)
125+
npm --prefix "./dirA" install --prefer-offline --no-audit --no-progress --legacy-peer-deps --ignore-scripts -q
126+
npm --prefix "./dirB/dirC" install --prefer-offline --no-audit --no-progress --legacy-peer-deps --ignore-scripts -q
127+
npm --prefix "./dirD/dirE/dirF" install --prefer-offline --no-audit --no-progress --legacy-peer-deps --ignore-scripts -q
128+
downloadUrl=$(curl -s "PLACEHOLDER_GETARTIFACTS_API?artifactName=RepoResults123&api-version=7.0" | jq -r ".resource.downloadUrl")
129+
wget -O RepoResults123.zip "$downloadUrl"
130+
unzip -p RepoResults123.zip RepoResults123/MockRepoOwner.MockRepoName.replay.txt > MockRepoOwner.MockRepoName.replay.txt
131+
npm install --no-save @typescript/server-replay
132+
\`\`\`
133+
134+
To run the repro:
135+
\`\`\`bash
136+
# \`npx tsreplay --help\` to learn about helpful switches for debugging, logging, etc.
137+
npx tsreplay ./MockRepoName ./MockRepoOwner.MockRepoName.replay.txt <PATH_TO_tsserver.js>
138+
\`\`\`
139+
140+
</details>
141+
142+
</details>
143+
",
144+
{
145+
"encoding": "utf-8",
146+
},
147+
],
148+
[
149+
"<BASE_PATH>/RepoResults123/metadata.json",
150+
"{"newTsResolvedVersion":"1.1.1","oldTsResolvedVersion":"0.0.0","statusCounts":{"Detected interesting changes":1}}",
151+
{
152+
"encoding": "utf-8",
153+
},
154+
],
155+
],
156+
"results": [
157+
{
158+
"type": "return",
159+
"value": undefined,
160+
},
161+
{
162+
"type": "return",
163+
"value": undefined,
164+
},
165+
{
166+
"type": "return",
167+
"value": undefined,
168+
},
169+
{
170+
"type": "return",
171+
"value": undefined,
172+
},
173+
{
174+
"type": "return",
175+
"value": undefined,
176+
},
177+
{
178+
"type": "return",
179+
"value": undefined,
180+
},
181+
{
182+
"type": "return",
183+
"value": undefined,
184+
},
185+
],
186+
}
187+
`;
188+
3189
exports[`main outputs server errors 1`] = `
4190
[MockFunction] {
5191
"calls": [
@@ -14,6 +200,10 @@ Maybe a Debug fail.
14200
at d (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:4:4)
15201
at e (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:5:5)",
16202
],
203+
[
204+
"<BASE_PATH>/ts_downloads/base/MockRepoOwner.MockRepoName.rawError.txt",
205+
"{"request_seq":"123","command":"cursedCommand","message":"Some error. Could not do something. \\nMaybe a Debug fail.\\n at a (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:1:1)\\n at b (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:2:2)\\n at c (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:3:3)\\n at d (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:4:4)\\n at e (/mnt/vss/_work/1/s/typescript-1.1.1/lib/typescript.js:5:5)"}",
206+
],
17207
[
18208
"<BASE_PATH>/RepoResults123/718e48b799650d4b66e5d80ad6bac7b9.results.txt",
19209
"<h2>Maybe a Debug fail.</h2>
@@ -91,6 +281,10 @@ npx tsreplay ./MockRepoName ./MockRepoOwner.MockRepoName.replay.txt <PATH_TO_tss
91281
"type": "return",
92282
"value": undefined,
93283
},
284+
{
285+
"type": "return",
286+
"value": undefined,
287+
},
94288
],
95289
}
96290
`;

0 commit comments

Comments
 (0)