mirror of
https://github.com/stablyai/orca.git
synced 2026-10-07 08:02:21 +00:00
fix(vault): read OpenCode SQLite inside WSL and SSH hosts (#23128)
* fix(vault): read OpenCode SQLite on WSL and SSH execution hosts * fix(vault): bound host setup and preserve cancellation across readers * fix(vault): keep WSL discovery visible and isolate probe tests * fix: retry local Vault runtime downloads without reserving remote stages Preserve verified remote cache reuse and latch only unresolved host work. Update WSL source-guard and remote dedup test integration. * fix(queue): discard aborted requests before respawn * fix(vault): preserve host paths and recover setup after reconnect * fix(ssh): fence every runtime platform probe across reconnects * fix(vault): reject setup results from superseded SSH connections --------- Co-authored-by: m4air <m4air@m4airs-Air.localdomain>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Worker } from 'node:worker_threads'
|
||||
import { getEventListeners } from 'node:events'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { WorkerThreadRequestQueue } from './worker-thread-request-queue'
|
||||
|
||||
@@ -103,6 +104,88 @@ describe('WorkerThreadRequestQueue', () => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
it('cancels queued requests without retiring active work and retires active cancellation', async () => {
|
||||
const workers: FakeWorker[] = []
|
||||
const queue = makeQueue(workers)
|
||||
const active = new AbortController()
|
||||
const queued = new AbortController()
|
||||
const first = settle(
|
||||
queue.dispatch((id) => ({ id, label: 'active' }), TIMEOUT_MS, active.signal)
|
||||
)
|
||||
const second = settle(
|
||||
queue.dispatch((id) => ({ id, label: 'queued' }), TIMEOUT_MS, queued.signal)
|
||||
)
|
||||
const third = send(queue, 'survivor')
|
||||
queued.abort(new Error('queued cancelled'))
|
||||
await expect(second).resolves.toMatchObject({ message: 'queued cancelled' })
|
||||
expect(workers[0].terminated).toBe(false)
|
||||
active.abort(new Error('active cancelled'))
|
||||
await expect(first).resolves.toMatchObject({ message: 'active cancelled' })
|
||||
expect(workers[0].terminated).toBe(true)
|
||||
expect(workers).toHaveLength(2)
|
||||
expect(labels(workers[1])).toEqual(['survivor'])
|
||||
workers[0].respond()
|
||||
workers[1].respond()
|
||||
await expect(third).resolves.toMatchObject({ label: 'survivor' })
|
||||
queue.dispose()
|
||||
})
|
||||
|
||||
it('never starts an already aborted request and rejects all work on disposal', async () => {
|
||||
const workers: FakeWorker[] = []
|
||||
const queue = makeQueue(workers)
|
||||
await expect(
|
||||
queue.dispatch(
|
||||
(id) => ({ id, label: 'aborted' }),
|
||||
TIMEOUT_MS,
|
||||
AbortSignal.abort(new Error('cancelled'))
|
||||
)
|
||||
).rejects.toThrow('cancelled')
|
||||
expect(workers).toHaveLength(0)
|
||||
const active = settle(send(queue, 'active'))
|
||||
const queued = settle(send(queue, 'queued'))
|
||||
queue.dispose()
|
||||
await expect(active).resolves.toMatchObject({ message: 'Worker request queue disposed' })
|
||||
await expect(queued).resolves.toMatchObject({ message: 'Worker request queue disposed' })
|
||||
await expect(send(queue, 'later')).rejects.toThrow('disposed')
|
||||
expect(workers[0].terminated).toBe(true)
|
||||
})
|
||||
|
||||
it.each([false, true])(
|
||||
'does not respawn for queued calls sharing the cancelled active signal (survivor: %s)',
|
||||
async (hasSurvivor) => {
|
||||
const workers: FakeWorker[] = []
|
||||
const queue = makeQueue(workers)
|
||||
const controller = new AbortController()
|
||||
const reason = new Error('scan cancelled')
|
||||
const pending = Array.from({ length: 8 }, (_, index) =>
|
||||
settle(
|
||||
queue.dispatch(
|
||||
(id) => ({ id, label: `cancelled-${index}` }),
|
||||
TIMEOUT_MS,
|
||||
controller.signal
|
||||
)
|
||||
)
|
||||
)
|
||||
const survivor = hasSurvivor ? send(queue, 'survivor') : undefined
|
||||
expect(getEventListeners(controller.signal, 'abort')).toHaveLength(8)
|
||||
|
||||
controller.abort(reason)
|
||||
|
||||
expect(await Promise.all(pending)).toEqual(Array.from({ length: 8 }, () => reason))
|
||||
expect(workers[0].terminated).toBe(true)
|
||||
expect(workers).toHaveLength(hasSurvivor ? 2 : 1)
|
||||
expect(workers.flatMap(labels)).toEqual(
|
||||
hasSurvivor ? ['cancelled-0', 'survivor'] : ['cancelled-0']
|
||||
)
|
||||
expect(getEventListeners(controller.signal, 'abort')).toHaveLength(0)
|
||||
if (survivor) {
|
||||
workers[1].respond()
|
||||
await expect(survivor).resolves.toMatchObject({ label: 'survivor' })
|
||||
}
|
||||
queue.dispose()
|
||||
}
|
||||
)
|
||||
|
||||
it('posts one request at a time and in the order it was dispatched', async () => {
|
||||
const workers: FakeWorker[] = []
|
||||
const queue = makeQueue(workers)
|
||||
|
||||
Reference in New Issue
Block a user