mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
* oom(01): A1-shared-readers — reintroduce #10179 subset Files: 18 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(02): A2-shared-image-media — reintroduce #10179 subset Files: 7 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(03): A3-shared-fs-listing — reintroduce #10179 subset Files: 21 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(04): A4-shared-remote-relay — reintroduce #10179 subset Files: 8 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(05): A5-shared-misc — reintroduce #10179 subset Files: 28 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(06): B-shared-wiring — reintroduce #10179 subset Files: 81 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { remoteRuntimeUnavailableError } from './remote-runtime-request-frames'
|
|
import { SharedControlSocketGeneration } from './remote-runtime-shared-control-socket-generation'
|
|
|
|
describe('SharedControlSocketGeneration', () => {
|
|
it('ignores stale close callbacks and accepts one close for the current socket', () => {
|
|
const generations = new SharedControlSocketGeneration()
|
|
const stale = generations.begin()
|
|
const current = generations.begin()
|
|
const closeSocket = vi.fn()
|
|
const onError = vi.fn()
|
|
const throwingOnError = vi.fn(() => {
|
|
throw new Error('consumer failed')
|
|
})
|
|
const subscriptions = new Map([
|
|
[
|
|
'subscription-1',
|
|
{
|
|
requestId: 'subscription-1',
|
|
method: 'session.tabs.subscribeAll',
|
|
params: null,
|
|
retainedParamsBytes: 0,
|
|
callbacks: { onResponse: vi.fn(), onError },
|
|
sent: true,
|
|
closed: false,
|
|
closeAfterReady: false,
|
|
remoteSubscriptionId: 'remote-1'
|
|
}
|
|
],
|
|
[
|
|
'subscription-2',
|
|
{
|
|
requestId: 'subscription-2',
|
|
method: 'runtime.clientEvents.subscribe',
|
|
params: null,
|
|
retainedParamsBytes: 0,
|
|
callbacks: { onResponse: vi.fn(), onError: throwingOnError },
|
|
sent: true,
|
|
closed: false,
|
|
closeAfterReady: false,
|
|
remoteSubscriptionId: 'remote-2'
|
|
}
|
|
]
|
|
])
|
|
const args = {
|
|
error: remoteRuntimeUnavailableError(),
|
|
everReady: true,
|
|
subscriptions,
|
|
closeSocket
|
|
}
|
|
|
|
expect(generations.acceptClose({ ...args, generation: stale })).toBe(false)
|
|
expect(generations.acceptClose({ ...args, generation: current })).toBe(true)
|
|
expect(generations.acceptClose({ ...args, generation: current })).toBe(false)
|
|
expect(closeSocket).toHaveBeenCalledTimes(1)
|
|
expect(onError).toHaveBeenCalledTimes(1)
|
|
expect(throwingOnError).toHaveBeenCalledTimes(1)
|
|
})
|
|
})
|