Skip to content

Commit 410e529

Browse files
committed
test: harden Windows trace and validation timeouts
1 parent 2abcca4 commit 410e529

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
supported-control-plane:
1414
name: Control plane (${{ matrix.os }}, Node ${{ matrix.node }})
1515
runs-on: ${{ matrix.os }}
16+
timeout-minutes: 30
1617
strategy:
1718
fail-fast: false
1819
matrix:

‎scripts/test-mcp-servers.js‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const { CLAUDE_MCP_JSON } = require('../index.js')
3030

3131
const ROOT = path.resolve(__dirname, '..')
3232
const TEMP_ROOT = path.join(os.tmpdir(), `devcodex-mcp-test-${process.pid}`)
33+
const PROFILE_TRACE_TIMEOUT_MS = 30_000
34+
const PROFILE_TRACE_MAX_BYTES = 1024 * 1024
3335

3436
function rpcRequest(id, method, params = {}) {
3537
return JSON.stringify({ jsonrpc: '2.0', id, method, params })
@@ -187,7 +189,12 @@ function runProfileServerWithReadTrace(requests, cwd) {
187189
"const originalReadFileSync = fs.readFileSync.bind(fs)",
188190
"const originalOpenSync = fs.openSync.bind(fs)",
189191
"const originalAppendFileSync = fs.appendFileSync.bind(fs)",
190-
"function trace(file) { try { originalAppendFileSync(process.env.DEVCODEX_READ_TRACE, JSON.stringify(String(file)) + '\\n') } catch {} }",
192+
"let tracing = false",
193+
"function trace(file) {",
194+
" if (tracing || String(file) === process.env.DEVCODEX_READ_TRACE) return",
195+
" tracing = true",
196+
" try { originalAppendFileSync(process.env.DEVCODEX_READ_TRACE, JSON.stringify(String(file)) + '\\n') } catch {} finally { tracing = false }",
197+
"}",
191198
"fs.readFileSync = function tracedReadFileSync(file, ...args) {",
192199
" trace(file)",
193200
" return originalReadFileSync(file, ...args)",
@@ -202,9 +209,18 @@ function runProfileServerWithReadTrace(requests, cwd) {
202209
cwd: ROOT,
203210
input,
204211
encoding: 'utf8',
205-
env: { ...process.env, DEVCODEX_READ_TRACE: tracePath }
212+
env: { ...process.env, DEVCODEX_READ_TRACE: tracePath },
213+
timeout: PROFILE_TRACE_TIMEOUT_MS
206214
})
207-
if (result.status !== 0) throw new Error((result.stderr || result.stdout || 'profile trace server failed').trim())
215+
if (result.error?.code === 'ETIMEDOUT') {
216+
throw new Error(`profile trace server exceeded ${PROFILE_TRACE_TIMEOUT_MS}ms`)
217+
}
218+
if (result.status !== 0) throw new Error((result.stderr || result.stdout || result.error?.message || 'profile trace server failed').trim())
219+
const traceBytes = fs.existsSync(tracePath) ? fs.statSync(tracePath).size : 0
220+
assert.ok(
221+
traceBytes <= PROFILE_TRACE_MAX_BYTES,
222+
`profile read trace exceeded ${PROFILE_TRACE_MAX_BYTES} bytes: ${traceBytes}`
223+
)
208224
const responses = result.stdout.trim().split(/\r?\n/).filter(Boolean).map(line => JSON.parse(line))
209225
const reads = fs.existsSync(tracePath)
210226
? fs.readFileSync(tracePath, 'utf8').split(/\r?\n/).filter(Boolean).map(line => JSON.parse(line))

‎scripts/validation-manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4484,7 +4484,7 @@
44844484
"writeScopes": [
44854485
"isolated-temp"
44864486
],
4487-
"timeoutMs": 180000,
4487+
"timeoutMs": 300000,
44884488
"exitMap": {
44894489
"success": [
44904490
0

0 commit comments

Comments
 (0)