fix: hold the upstream resync until the OpenCode proxy accepts requests (OM-179)

This commit is contained in:
Chris Scott committed 2026-11-03 00:06:39 -05:00
1 parent 9fca96ecea
commit 3e6ebbd1dc
6 files changed
+103 -1

No files matched your search

@@ -3242,6 +3242,24 @@ describe('OpenCodeServerManager - server auth', () => {
expect(manager.isRestartPending()).toBe(false)
})
it('notifies lifecycle listeners only when the gate opens', async () => {
const { OpenCodeServerManager } = await import('../../src/services/opencode-single-server')
const manager = OpenCodeServerManager.getInstance()
const listener = vi.fn()
const unsubscribe = manager.onLifecycleInitialized(listener)
manager.setLifecycleInitialized(false)
manager.setLifecycleInitialized(true)
manager.setLifecycleInitialized(true)
manager.setLifecycleInitialized(false)
manager.setLifecycleInitialized(true)
unsubscribe()
manager.setLifecycleInitialized(false)
manager.setLifecycleInitialized(true)
expect(listener).toHaveBeenCalledTimes(2)
})
function setOpenCodeEnv(values: { host: string; password: string }) {
Object.defineProperty(ENV.OPENCODE, 'HOST', { value: values.host, configurable: true, writable: true })
Object.defineProperty(ENV.OPENCODE, 'SERVER_PASSWORD', { value: values.password, configurable: true, writable: true })