mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(sandbox): bound lifecycle queue and harden install/backup paths
Bound the OpenCode supervisor lifecycle queue to one running plus one pending operation so repeated restarts cannot stack unbounded HTTP requests, while exempting stop() so shutdown is never dropped. Reject enforcement backups that carry no recoverable removed sections, matching the existing fail-closed handling of unparseable backups. Install OpenCode through a private mktemp staging directory instead of the predictable /tmp/opencode path. Use named path/os imports in the files added by this branch.
This commit is contained in:
1 parent
0481160f5e
commit
0215de9d92
9 files changed
+108
-28
No files matched your search
@@ -570,4 +570,34 @@ describe('OpenCodeSupervisor', () => {
|
||||
expect(manager.restart).toHaveBeenCalledTimes(1)
|
||||
expect(manager.stop).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('drops a restart stacked behind an already queued restart but never drops a stop', async () => {
|
||||
const manager = createManager()
|
||||
const settings = createSettings()
|
||||
const supervisor = new OpenCodeSupervisor(manager as unknown as never, settings as unknown as never, {
|
||||
failureThreshold: 1,
|
||||
watchEnabled: false,
|
||||
})
|
||||
|
||||
let releaseRestart!: () => void
|
||||
manager.restart.mockImplementationOnce(
|
||||
() => new Promise<void>((resolve) => { releaseRestart = resolve }),
|
||||
)
|
||||
manager.checkHealth.mockResolvedValue(true)
|
||||
|
||||
const running = supervisor.restart('manual')
|
||||
await vi.waitFor(() => expect(manager.restart).toHaveBeenCalledTimes(1))
|
||||
|
||||
const queued = supervisor.restart('manual')
|
||||
const dropped = supervisor.restart('manual')
|
||||
const stopPromise = supervisor.stop()
|
||||
|
||||
await expect(dropped).resolves.toMatchObject({ state: 'starting' })
|
||||
|
||||
releaseRestart()
|
||||
await Promise.all([running, queued, stopPromise])
|
||||
|
||||
expect(manager.restart).toHaveBeenCalledTimes(2)
|
||||
expect(manager.stop).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user