fix(subagent): expose startup cleanup failure facts
This commit is contained in:
1 parent
a3a9f86d89
commit
77211b1c26
2 files changed
+18
-10
No files matched your search
@@ -453,9 +453,10 @@ export async function startClaudeCodeRun(
|
||||
await disposeClaudeCodeChild(query, child)
|
||||
} catch (disposeError: unknown) {
|
||||
const failure = startupFailure()
|
||||
const cleanupFailure = thrown(disposeError)
|
||||
throw new AggregateError(
|
||||
[failure, thrown(disposeError)],
|
||||
`${failure.message}; startup cleanup also failed`,
|
||||
[failure, cleanupFailure],
|
||||
`${failure.message}; ${cleanupFailure.message}`,
|
||||
)
|
||||
}
|
||||
} else if (query !== undefined) {
|
||||
@@ -463,15 +464,13 @@ export async function startClaudeCodeRun(
|
||||
query.close()
|
||||
} catch (disposeError: unknown) {
|
||||
const failure = startupFailure()
|
||||
const cleanupFailure = new ClaudeCodeFailure({
|
||||
stage: 'teardown',
|
||||
category: 'unknown',
|
||||
}, thrown(disposeError))
|
||||
throw new AggregateError(
|
||||
[
|
||||
failure,
|
||||
new ClaudeCodeFailure({
|
||||
stage: 'teardown',
|
||||
category: 'unknown',
|
||||
}, thrown(disposeError)),
|
||||
],
|
||||
`${failure.message}; startup cleanup also failed`,
|
||||
[failure, cleanupFailure],
|
||||
`${failure.message}; ${cleanupFailure.message}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1087,6 +1087,9 @@ describe('run publication, cancellation, and settlement', () => {
|
||||
})
|
||||
await expect(noChild)
|
||||
.rejects.toThrow(expectedFailureDiagnostic('query-start', 'unknown'))
|
||||
await expect(noChild).rejects.toThrow(
|
||||
`${expectedFailureDiagnostic('query-start', 'unknown')}; subagent-claude-code: ${expectedFailureDiagnostic('teardown', 'unknown')}`,
|
||||
)
|
||||
await expect(noChild).rejects.toBeInstanceOf(AggregateError)
|
||||
|
||||
const startupAbort = new AbortController()
|
||||
@@ -1129,6 +1132,9 @@ describe('run publication, cancellation, and settlement', () => {
|
||||
.rejects.toBeInstanceOf(AggregateError)
|
||||
await expect(cancelledCleanupFailure)
|
||||
.rejects.toThrow(expectedFailureDiagnostic('query-start', 'unknown'))
|
||||
await expect(cancelledCleanupFailure).rejects.toThrow(
|
||||
`${expectedFailureDiagnostic('query-start', 'unknown')}; subagent-claude-code: ${expectedFailureDiagnostic('teardown', 'unknown', { exitCode: 0, signal: null })}`,
|
||||
)
|
||||
await expect(cancelledCleanupFailure)
|
||||
.rejects.not.toThrow('SECRET_TOKEN')
|
||||
|
||||
@@ -1196,6 +1202,9 @@ describe('run publication, cancellation, and settlement', () => {
|
||||
const failedStartup = startClaudeCodeRun(request(), failed.spec)
|
||||
await expect(failedStartup)
|
||||
.rejects.toThrow(expectedFailureDiagnostic('query-start', 'unknown'))
|
||||
await expect(failedStartup).rejects.toThrow(
|
||||
`${expectedFailureDiagnostic('query-start', 'unknown')}; subagent-claude-code: ${expectedFailureDiagnostic('teardown', 'unknown')}`,
|
||||
)
|
||||
await expect(failedStartup).rejects.toBeInstanceOf(AggregateError)
|
||||
expect(failed.close).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user