MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / removeWhenReleased

Function removeWhenReleased

__tests__/mcp-initialize.test.ts:124–136  ·  view source on GitHub ↗

* Remove `dir` once nothing holds it. Even after the killed server's 'close', * Windows can keep the dir itself busy a moment longer under load, and * `fs.rmSync`'s `maxRetries` never retries EBUSY on a directory: it throws at * once. A dir still held at the deadline fails the test.

(dir: string, timeoutMs = 5000)

Source from the content-addressed store, hash-verified

122 * once. A dir still held at the deadline fails the test.
123 */
124async function removeWhenReleased(dir: string, timeoutMs = 5000): Promise<void> {
125 const deadline = Date.now() + timeoutMs;
126 for (;;) {
127 try {
128 fs.rmSync(dir, { recursive: true, force: true });
129 return;
130 } catch (error) {
131 const code = (error as NodeJS.ErrnoException).code ?? '';
132 if (!['EBUSY', 'ENOTEMPTY', 'EPERM'].includes(code) || Date.now() > deadline) throw error;
133 await new Promise((resolve) => setTimeout(resolve, 50));
134 }
135 }
136}
137
138describe('MCP server title and icon', () => {
139 it('names the server and carries an icon no host has to fetch', () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected