mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 00:03:45 +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>
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { mapSettledWithConcurrency } from './map-with-concurrency'
|
|
|
|
describe('mapSettledWithConcurrency', () => {
|
|
it('preserves all-settled results and order while bounding a large fanout', async () => {
|
|
const limit = 7
|
|
const items = Array.from({ length: 1_000 }, (_, index) => index)
|
|
let inFlight = 0
|
|
let peak = 0
|
|
|
|
const results = await mapSettledWithConcurrency(items, limit, async (item) => {
|
|
inFlight += 1
|
|
peak = Math.max(peak, inFlight)
|
|
await Promise.resolve()
|
|
for (let turn = 0; turn < item % 5; turn += 1) {
|
|
await Promise.resolve()
|
|
}
|
|
inFlight -= 1
|
|
if (item % 97 === 0) {
|
|
throw `rejected-${item}`
|
|
}
|
|
return `fulfilled-${item}`
|
|
})
|
|
|
|
expect(peak).toBe(limit)
|
|
expect(results).toEqual(
|
|
items.map(
|
|
(item): PromiseSettledResult<string> =>
|
|
item % 97 === 0
|
|
? { status: 'rejected', reason: `rejected-${item}` }
|
|
: { status: 'fulfilled', value: `fulfilled-${item}` }
|
|
)
|
|
)
|
|
})
|
|
})
|