Skip to content

Commit 4f1d7d2

Browse files
committed
chore: debug linux watcher (temporary, do not merge)
1 parent ba6c1b2 commit 4f1d7d2

2 files changed

Lines changed: 69 additions & 1 deletion

File tree

‎packages/vscode/e2e/rstest/runTest.ts‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,44 @@
1818
* the shell probe never runs.
1919
*/
2020
import { createHash } from 'node:crypto';
21+
import { execFileSync } from 'node:child_process';
2122
import {
2223
cpSync,
2324
existsSync,
2425
mkdtempSync,
26+
readFileSync,
27+
readlinkSync,
28+
readdirSync,
2529
rmSync,
30+
statSync,
2631
writeFileSync,
2732
} from 'node:fs';
2833
import { tmpdir } from 'node:os';
2934
import path from 'node:path';
3035
import { runTests } from '@vscode/test-electron';
36+
37+
// TEMPORARY (debug/linux-watcher): how many inotify instances the system is
38+
// currently holding — the ceiling that panel runs hit (max_user_instances).
39+
const countInotifyFds = (): number => {
40+
let count = 0;
41+
for (const entry of readdirSync('/proc')) {
42+
if (!/^\d+$/.test(entry)) continue;
43+
try {
44+
for (const fd of readdirSync(`/proc/${entry}/fd`)) {
45+
const target = readlinkSync(`/proc/${entry}/fd/${fd}`);
46+
if (
47+
target === 'anon_inode:inotify' ||
48+
target === 'anon_inode:[inotify]'
49+
) {
50+
count += 1;
51+
}
52+
}
53+
} catch {
54+
// A process may exit between listing and reading; ignore.
55+
}
56+
}
57+
return count;
58+
};
3159
import { vscodeTestCachePath } from '../vscodeTestCache';
3260

3361
// Repo-relative fixture dirs whose installs this slice needs. workspace-2 has
@@ -51,6 +79,41 @@ async function main() {
5179
'e2e/rstest/fixtures',
5280
);
5381

82+
// TEMPORARY environment diagnostics for the debug/linux-watcher branch.
83+
// One-off lines in the job output so a runner-side copy of the failing
84+
// ecosystem-ci context can be compared against local/leg tracks.
85+
if (process.env.CI === 'true' || process.env.RSTACK_DETECTION_DIAG === '1') {
86+
const procRoot = '/proc/sys/fs/inotify';
87+
try {
88+
console.error(`[e2e-env] time ${new Date().toISOString()}`);
89+
console.error(
90+
`[e2e-env] node ${process.version} ${process.platform} ${process.arch}`,
91+
);
92+
console.error(
93+
`[e2e-env] fixtures ${fixturesRoot}`,
94+
`root-dev=${statSync(fixturesRoot).dev}`,
95+
);
96+
for (const limit of [
97+
'max_user_watches',
98+
'max_user_instances',
99+
'max_queued_events',
100+
]) {
101+
console.error(
102+
`[e2e-env] inotify ${limit} ${readFileSync(`${procRoot}/${limit}`, 'utf8').trim()}`,
103+
);
104+
}
105+
console.error(`[e2e-env] inotify instances in use: ${countInotifyFds()}`);
106+
console.error(
107+
`[e2e-env] df -T fixtures:\n${execFileSync('df', ['-T', fixturesRoot], { encoding: 'utf8' })}`,
108+
);
109+
console.error(
110+
`[e2e-env] toolchain override ${process.env.RSTACK_E2E_TOOLCHAIN_OVERRIDES || '(unset)'}`,
111+
);
112+
} catch (error) {
113+
console.error(`[e2e-env] diagnostics failed: ${error}`);
114+
}
115+
}
116+
54117
// The extension host loads `main` from `package.json`; an unbuilt repo would
55118
// otherwise fail deep inside VS Code with an unhelpful activation error.
56119
if (!existsSync(path.join(extensionDevelopmentPath, 'dist/extension.js'))) {

‎packages/vscode/src/detection.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ import {
1414
* captures it: folder-set changes, watcher installation, every watcher event,
1515
* detection passes and their discovered config files.
1616
*/
17-
const DIAG = !!process.env.RSTACK_DETECTION_DIAG;
17+
// Default-on in CI for this temporary branch: rstack-ecosystem-ci passes no
18+
// RSTACK_DETECTION_DIAG, and the whole point is to capture the diag lines from
19+
// a run there — CI='true' is set both by the editor's own workflows and by
20+
// ecosystem-ci.
21+
const DIAG =
22+
process.env.RSTACK_DETECTION_DIAG === '1' || process.env.CI === 'true';
1823
const diag = (...args: unknown[]): void => {
1924
if (DIAG) {
2025
console.error(`[detection-diag ${new Date().toISOString()}]`, ...args);

0 commit comments

Comments
 (0)