Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mcpx",
"version": "0.10.1",
"version": "0.10.2",
"license": "MIT",
"bin": {
"mcpx": "./src/main.ts"
Expand Down
13 changes: 10 additions & 3 deletions tests/runtime-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ describe('Runtime CLI adapter lifecycle', () => {
}, 10_000)

it('single-flights five explicit refresh CLI processes through one local token request', async () => {
const fixture = startHttpFixture()
// Keep the flow active while independently booting Bun processes reach the
// warm daemon; the assertion is about overlapping callers, not loader speed.
const fixture = startHttpFixture({ tokenDelayMs: 500 })
await seedExpiredOAuth(fixture.url, fixture.issuer)
// Cold-start polling can let the first 25 ms refresh finish before later
// processes connect; start the daemon so this test isolates flow sharing.
expect((await runCli(['@daemon', 'status', '--raw'])).exitCode).toBe(0)
const refreshes = Array.from({ length: 5 }, () =>
spawnObserved(['@refresh', '--raw']),
)
Expand Down Expand Up @@ -232,7 +237,9 @@ function isAlive(pid: number): boolean {
}
}

function startHttpFixture(options: { holdToken?: boolean } = {}): {
function startHttpFixture(
options: { holdToken?: boolean; tokenDelayMs?: number } = {},
): {
url: string
issuer: string
tokenRequests: () => number
Expand All @@ -255,7 +262,7 @@ function startHttpFixture(options: { holdToken?: boolean } = {}): {
if (requestUrl.pathname === '/token') {
tokenRequests += 1
if (options.holdToken) await new Promise(() => {})
await Bun.sleep(25)
await Bun.sleep(options.tokenDelayMs ?? 25)
return Response.json({
access_token: 'local-access',
refresh_token: 'local-refresh-2',
Expand Down