diff --git a/src/commands/cloud.ts b/src/commands/cloud.ts index d1b5908..9dd38ac 100644 --- a/src/commands/cloud.ts +++ b/src/commands/cloud.ts @@ -358,12 +358,12 @@ export const cloudCommand = defineCommand({ const auth = await resolveAuth({ apiKeyFlag }); - // Nudge interactive api-key users toward `dcd login`, which unlocks live - // (realtime) status updates. Suppressed in CI and non-interactive output. + // Nudge interactive api-key users toward `dcd login`. Suppressed in CI and + // non-interactive output. if (auth.mode === 'apiKey' && !json && !quiet && !isCI()) { out( colors.dim( - 'Tip: run `dcd login` for live test updates and a smoother experience than passing --api-key.', + 'Tip: run `dcd login` for a smoother experience than passing --api-key.', ), ); } diff --git a/src/commands/login.ts b/src/commands/login.ts index 553cf2b..5ec68df 100644 --- a/src/commands/login.ts +++ b/src/commands/login.ts @@ -36,12 +36,10 @@ import { defineCommand } from 'citty'; import { createHash, randomBytes } from 'node:crypto'; import { - type DcdEnvName, ENVIRONMENTS, inferEnvFromApiUrl, resolveFrontendUrl, } from '../config/environments.js'; -import { getSupabaseKey } from '../config/supabase-key.js'; import { jsonFlag } from '../config/flags/output.flags.js'; import { openBrowser } from '../utils/browser.js'; import { canPrompt } from '../utils/ci.js'; @@ -201,17 +199,11 @@ export const loginCommand = defineCommand({ try { orgs = await fetchOrgs(apiUrl, bearerHeaders); } catch (err) { - // The api rejected the JWT. Before blaming the api, hit Supabase's - // own /auth/v1/user directly with the same token — if Supabase also - // rejects it, the token itself is bad; if Supabase accepts, the - // api's JwtService is misconfigured. + // The api rejected the JWT it just minted. Name the token's issuer, so + // a token from the wrong environment is plain from the error. const iss = decodeJwtIssuer(payload.access_token); - const supabaseUser = await probeSupabaseUser(iss, env, payload.access_token); - const parts = [ - iss ? `token iss: ${iss}` : null, - `supabase /auth/v1/user: ${supabaseUser}`, - ].filter(Boolean); - throw new CliError(`${(err as Error).message} [${parts.join(' | ')}]`); + const message = (err as Error).message; + throw new CliError(iss ? `${message} [token iss: ${iss}]` : message); } const { org: chosen, fromLastLogin } = await selectOrg(orgs, { requested: requestedOrg, @@ -319,26 +311,6 @@ function base64url(buf: Buffer): string { return buf.toString('base64').replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, ''); } -async function probeSupabaseUser( - iss: string | null, - env: DcdEnvName, - token: string, -): Promise { - if (!iss) return 'skipped (no iss)'; - try { - const res = await fetch(`${iss}/user`, { - headers: { - authorization: `Bearer ${token}`, - apikey: await getSupabaseKey(env), - }, - }); - const bodyText = await res.text().catch(() => ''); - return `HTTP ${res.status}${bodyText ? ` — ${bodyText.slice(0, 200)}` : ''}`; - } catch (err) { - return `network error: ${(err as Error).message}`; - } -} - function decodeJwtIssuer(token: string): string | null { try { const [, payloadB64] = token.split('.'); diff --git a/src/commands/logout.ts b/src/commands/logout.ts index be2a163..bd72e2f 100644 --- a/src/commands/logout.ts +++ b/src/commands/logout.ts @@ -1,11 +1,11 @@ /** - * `dcd logout` — clears the stored Supabase session and best-effort revokes - * it on Supabase. Leaves DEVICE_CLOUD_API_KEY (env/flag) untouched. + * `dcd logout` — deletes the stored session. Local only: nothing is revoked + * server-side, so the user stays signed in to the web app and any other CLI. + * Leaves DEVICE_CLOUD_API_KEY (env/flag) untouched. */ import { defineCommand } from 'citty'; import { jsonFlag } from '../config/flags/output.flags.js'; -import { CliAuthGateway } from '../gateways/cli-auth-gateway.js'; import { logger } from '../utils/cli.js'; import { clearConfig, getConfigPath, readConfig } from '../utils/config-store.js'; import { colors } from '../utils/styling.js'; @@ -32,7 +32,6 @@ export const logoutCommand = defineCommand({ return; } - await CliAuthGateway.signOut(config.supabase_url, config.env, config.session); clearConfig(); if (json) { logger.json({ status: 'SUCCESS', loggedOut: true, user: config.session.user_email }); diff --git a/src/gateways/cli-auth-gateway.ts b/src/gateways/cli-auth-gateway.ts index 96686ef..bee282e 100644 --- a/src/gateways/cli-auth-gateway.ts +++ b/src/gateways/cli-auth-gateway.ts @@ -112,26 +112,4 @@ export const CliAuthGateway = { user_id: u.id, }; }, - - async signOut( - supabaseUrl: string, - env: DcdEnvName, - session: StoredSession, - ): Promise { - // `scope: 'local'` clears this client's SDK state only — no server call, - // no revocation. supabase-js defaults to `scope: 'global'`, which revokes - // EVERY session for the user (browser, mobile, other CLIs), so - // `dcd logout` would kick the user out of the web app. We don't want - // that — logging out locally should be local. - try { - const sb = client(supabaseUrl, await getSupabaseKey(env)); - await sb.auth.setSession({ - access_token: session.access_token, - refresh_token: session.refresh_token, - }); - await sb.auth.signOut({ scope: 'local' }); - } catch { - // Best effort — the local config will be wiped regardless. - } - }, }; diff --git a/src/gateways/realtime-gateway.ts b/src/gateways/realtime-gateway.ts deleted file mode 100644 index 2ede962..0000000 --- a/src/gateways/realtime-gateway.ts +++ /dev/null @@ -1,183 +0,0 @@ -/** - * Supabase Realtime subscription to test-result status changes. - * - * This is a *latency optimisation* layered on top of HTTP polling, not a - * replacement for it. A logged-in (bearer) user's JWT authorises a - * `postgres_changes` subscription on the `results` table (RLS scopes rows to - * the user's org via `app_metadata.org_ids`). Each relevant change fires - * `onChange`, which the polling loop uses to fetch immediately instead of - * waiting out the full backstop interval. - * - * We deliberately only read the `new` row's `test_upload_id` — Postgres always - * ships the full new tuple on INSERT/UPDATE regardless of REPLICA IDENTITY, so - * no DB change is required. Mirrors the frontend pattern in - * dcd/frontend/app/stores/Results.store.ts. - */ -import { - createClient, - REALTIME_SUBSCRIBE_STATES, - type RealtimeChannel, - type SupabaseClient, -} from '@supabase/supabase-js'; - -import { ENVIRONMENTS, type DcdEnvName } from '../config/environments.js'; -import { getSupabaseKey } from '../config/supabase-key.js'; - -export interface RealtimeResultsSubscription { - /** - * Whether the channel is currently subscribed and receiving pushes. False - * until the socket subscribes, and again if it errors/closes — the backstop - * poll always covers the gap. - */ - isConnected(): boolean; - /** Tear down the channel and close the socket. Best-effort, never throws. */ - unsubscribe(): Promise; - /** - * Hand the socket a refreshed JWT. RLS authorises the channel with the token - * it joined with, and the server drops the channel once that expires — so a - * poll that outlives the token passes the new one on. Best-effort, never - * throws. - */ - updateAccessToken(accessToken: string): void; -} - -export interface RealtimeSubscribeOptions { - /** Supabase JWT (AuthContext.accessToken) — authorises the socket for RLS. */ - accessToken: string; - debug?: boolean; - env: DcdEnvName; - /** Stderr-safe logger; stdout is reserved by some callers (MCP). */ - log?: (message: string) => void; - /** Fired when a result row for this upload changes. */ - onChange: () => void; - /** Fired whenever the connection state flips (subscribed ↔ disconnected). */ - onConnectionChange?: (connected: boolean) => void; - orgId: string; - uploadId: string; -} - -/** - * The `new` record we care about from a `results` row change. Loosely typed — - * we only ever read `test_upload_id`. - */ -interface ResultChangePayload { - new?: { test_upload_id?: string } | null; -} - -export class RealtimeResultsGateway { - /** - * Open a realtime subscription to `results` changes for the given upload. - * Construction never throws — on any failure the caller simply keeps polling. - */ - static subscribe( - options: RealtimeSubscribeOptions, - ): RealtimeResultsSubscription { - const { accessToken, debug, env, log, onChange, onConnectionChange, orgId, uploadId } = options; - const dbg = (message: string) => { - if (debug && log) log(`[DEBUG] [realtime] ${message}`); - }; - - let connected = false; - const setConnected = (next: boolean) => { - if (next === connected) return; - connected = next; - onConnectionChange?.(next); - }; - - let client: SupabaseClient | undefined; - let channel: RealtimeChannel | undefined; - let closed = false; - // The latest JWT, so a refresh that lands while the key is still being - // fetched is the one the socket joins with. - let token = accessToken; - - // The publishable key comes from the API (dcd#1112), so the socket opens - // asynchronously. `subscribe` stays synchronous for the caller: until it - // connects, `isConnected` is false and the backstop poll covers the gap. - const ready = getSupabaseKey(env) - .then((supabaseKey) => { - if (closed) return; - const sb = createClient(ENVIRONMENTS[env].supabase.url, supabaseKey, { - // Match SupabaseClientGateway / the frontend; no session persistence — - // we set the token explicitly below. - auth: { autoRefreshToken: false, persistSession: false }, - realtime: { params: { eventsPerSecond: 10 } }, - }); - client = sb; - - // Attach the user's JWT to the socket so RLS is enforced on the channel. - sb.realtime.setAuth(token); - - channel = sb - .channel(`results-cli-${uploadId}`) - .on( - // The typings don't cover the postgres_changes overload cleanly. - 'postgres_changes' as never, - { - event: '*', - schema: 'public', - table: 'results', - filter: `org_id=eq.${orgId}`, - } as never, - (payload: ResultChangePayload) => { - if (payload.new?.test_upload_id === uploadId) { - dbg(`change for upload ${uploadId}`); - onChange(); - } - }, - ) - .subscribe((status) => { - if (status === REALTIME_SUBSCRIBE_STATES.SUBSCRIBED) { - dbg('subscribed'); - setConnected(true); - } else if ( - status === REALTIME_SUBSCRIBE_STATES.CHANNEL_ERROR || - status === REALTIME_SUBSCRIBE_STATES.TIMED_OUT || - status === REALTIME_SUBSCRIBE_STATES.CLOSED - ) { - // Don't try to recover — the backstop poll covers us. Surface in - // debug so a network-blocked websocket is diagnosable. - dbg(`channel ${status}; relying on backstop poll`); - setConnected(false); - } - }); - }) - .catch((error: unknown) => { - dbg(`failed to subscribe: ${error instanceof Error ? error.message : String(error)}`); - // Best-effort cleanup of a half-built client, then degrade to polling. - try { - client?.realtime.disconnect(); - } catch { - /* ignore */ - } - client = undefined; - channel = undefined; - }); - - return { - isConnected: () => connected, - async unsubscribe() { - closed = true; - setConnected(false); - await ready; - if (!client) return; - try { - if (channel) await client.removeChannel(channel); - await client.realtime.disconnect(); - } catch { - /* best effort — process is exiting anyway */ - } - }, - updateAccessToken(nextToken: string) { - token = nextToken; - // setAuth updates the join payload and pushes the token to joined - // channels. A failure only costs realtime; the backstop poll stays. - client?.realtime.setAuth(nextToken).catch((error: unknown) => { - dbg( - `failed to update the socket's token: ${error instanceof Error ? error.message : String(error)}`, - ); - }); - }, - }; - } -} diff --git a/src/services/results-polling.service.ts b/src/services/results-polling.service.ts index 11e7c99..8840d82 100644 --- a/src/services/results-polling.service.ts +++ b/src/services/results-polling.service.ts @@ -1,10 +1,6 @@ import * as path from 'node:path'; import { ApiGateway, type ResultsPollCache } from '../gateways/api-gateway.js'; -import { - RealtimeResultsGateway, - type RealtimeResultsSubscription, -} from '../gateways/realtime-gateway.js'; import { formatDurationSeconds } from '../methods.js'; import type { AuthContext } from '../types/domain/auth.types.js'; import { paths } from '../types/generated/schema.types.js'; @@ -170,11 +166,9 @@ export class ResultsPollingService { // giving up. Losing a run to a brief hiccup is far more costly than waiting a // bit longer. private readonly MAX_SEQUENTIAL_FAILURES = 30; - // Backstop poll cadence. Logged-in (bearer) users also get realtime pushes - // (see RealtimeResultsGateway), so they only need an occasional reconciling - // poll; api-key users have no realtime and rely on the faster interval. - private readonly BEARER_POLL_INTERVAL_MS = 60_000; - private readonly APIKEY_POLL_INTERVAL_MS = 20_000; + // Poll cadence, the same for API-key and `dcd login` auth. A poll that finds + // nothing changed costs an empty 304 (see ResultsPollCache). + private readonly POLL_INTERVAL_MS = 20_000; // Base unit for the backoff applied between *failed* polls, and its cap. private readonly ERROR_BACKOFF_BASE_MS = 10_000; private readonly MAX_ERROR_BACKOFF_MS = 30_000; @@ -219,48 +213,12 @@ export class ResultsPollingService { // gets an empty 304 instead of the whole set again. const resultsCache: ResultsPollCache = {}; - const pollIntervalMs = - auth.mode === 'bearer' - ? this.BEARER_POLL_INTERVAL_MS - : this.APIKEY_POLL_INTERVAL_MS; - - // "Poke" mechanism: a realtime change resolves the current inter-poll wait - // early. If a poke lands while we're mid-fetch (not waiting) it's latched - // and consumed by the next wait, so events are never silently dropped. - let resolveWake: (() => void) | null = null; - let pendingPoke = false; - const poke = () => { - if (resolveWake) { - const r = resolveWake; - resolveWake = null; - r(); - } else { - pendingPoke = true; - } - }; - const waitForNextPoll = (ms: number): Promise => { - if (pendingPoke) { - pendingPoke = false; - return Promise.resolve(); - } - return new Promise((resolve) => { - const timer = setTimeout(() => { - resolveWake = null; - resolve(); - }, ms); - resolveWake = () => { - clearTimeout(timer); - resolve(); - }; - }); - }; + const pollIntervalMs = this.POLL_INTERVAL_MS; // Live display state, recomposed by renderStatus() so the footer (countdown - // to the next backstop poll + realtime connection state) stays current - // between polls without re-fetching. `nextPollAt` is an epoch-ms deadline - // while waiting, or null while a fetch is in flight. - let subscription: RealtimeResultsSubscription | undefined; - let realtimeEnabled = false; + // to the next poll) stays current between polls without re-fetching. + // `nextPollAt` is an epoch-ms deadline while waiting, or null while a + // fetch is in flight. let statusBody = ''; let nextPollAt: null | number = null; // The animated footer/countdown only makes sense on a TTY. In CI/pipes it @@ -273,39 +231,10 @@ export class ResultsPollingService { ux.action.status = statusBody; return; } - const footer = this.buildStatusFooter( - realtimeEnabled, - subscription?.isConnected() ?? false, - nextPollAt, - quiet, - ); + const footer = this.buildStatusFooter(nextPollAt, quiet); ux.action.status = footer ? `${statusBody}\n${footer}` : statusBody; }; - // Realtime is a latency optimisation over the backstop poll; only logged-in - // (bearer) users can authenticate the socket under RLS. Any failure inside - // the gateway degrades silently to pure polling. - if (auth.mode === 'bearer' && auth.accessToken && auth.orgId && auth.env) { - realtimeEnabled = true; - subscription = RealtimeResultsGateway.subscribe({ - accessToken: auth.accessToken, - debug, - env: auth.env, - log: logger, - onChange: poke, - // Reflect connect/disconnect in the live footer immediately rather than - // waiting for the next ticker frame. - onConnectionChange: renderStatus, - orgId: auth.orgId, - uploadId, - }); - if (debug && logger) { - logger( - `[DEBUG] Realtime enabled; backstop poll every ${pollIntervalMs / 1000}s`, - ); - } - } - if (debug && logger) { logger(`[DEBUG] Starting polling loop for results`); } @@ -327,7 +256,7 @@ export class ResultsPollingService { nextPollAt = null; renderStatus(); - auth = await this.refreshPollingAuth(auth, uploadId, subscription, debug, logger); + auth = await this.refreshPollingAuth(auth, uploadId, debug, logger); const updatedResults = await this.fetchAndLogResults( apiUrl, auth, @@ -360,11 +289,10 @@ export class ResultsPollingService { // Reset failure counter on successful poll sequentialPollFailures = 0; - // Wait for the next backstop poll, or a realtime poke, whichever comes - // first, while the footer counts down to the deadline. + // Wait for the next poll while the footer counts down to it. nextPollAt = Date.now() + pollIntervalMs; renderStatus(); - await waitForNextPoll(pollIntervalMs); + await this.sleep(pollIntervalMs); } catch (error) { // Re-throw RunFailedError immediately (test failures, not polling // errors), and an expired login no retry can fix. @@ -397,12 +325,6 @@ export class ResultsPollingService { if (ticker) { clearInterval(ticker); } - if (subscription) { - if (debug && logger) { - logger('[DEBUG] Closing realtime subscription'); - } - await subscription.unsubscribe(); - } } } @@ -604,12 +526,11 @@ export class ResultsPollingService { /** * Swap in a fresh `dcd login` token when the current one is about to - * expire, and hand it to the realtime socket too; API-key auth comes back - * as-is. A transient refresh failure is thrown as-is, to be retried like - * any failed poll; one only `dcd login` can fix becomes a PollingAuthError. + * expire; API-key auth comes back as-is. A transient refresh failure is + * thrown as-is, to be retried like any failed poll; one only `dcd login` + * can fix becomes a PollingAuthError. * @param auth The credential the previous poll used * @param uploadId Upload being polled, for the reconnect hint - * @param subscription Realtime subscription to pass a new token to * @param debug Whether debug logging is enabled * @param logger Optional logger function * @returns The credential for the next poll @@ -617,7 +538,6 @@ export class ResultsPollingService { private async refreshPollingAuth( auth: AuthContext, uploadId: string, - subscription: RealtimeResultsSubscription | undefined, debug: boolean, logger?: (message: string) => void, ): Promise { @@ -637,14 +557,8 @@ export class ResultsPollingService { throw error; } - if (next !== auth) { - if (debug && logger) { - logger('[DEBUG] Refreshed the dcd login session for polling'); - } - - if (next.accessToken && next.accessToken !== auth.accessToken) { - subscription?.updateAccessToken(next.accessToken); - } + if (next !== auth && debug && logger) { + logger('[DEBUG] Refreshed the dcd login session for polling'); } return next; @@ -851,7 +765,7 @@ export class ResultsPollingService { /** * Build the body of the live status display (the per-test table, or just the - * one-line summary in quiet mode). The footer (countdown + realtime state) is + * one-line summary in quiet mode). The footer (the countdown) is * appended separately by {@link buildStatusFooter} so it can re-render on a * timer without re-fetching. */ @@ -876,38 +790,20 @@ export class ResultsPollingService { } /** - * Build the live footer shown under the status display: whether realtime - * updates are connected (for logged-in users) and how long until the next - * backstop poll. While a fetch is in flight (`nextPollAt` is null) the - * countdown reads "refreshing…". In quiet mode the countdown is omitted. + * Build the live footer shown under the status display: how long until the + * next poll. While a fetch is in flight (`nextPollAt` is null) it reads + * "refreshing…". In quiet mode (geared at CI) the footer is omitted. */ - private buildStatusFooter( - realtimeEnabled: boolean, - realtimeConnected: boolean, - nextPollAt: null | number, - quiet: boolean, - ): string { - const parts: string[] = []; - - if (realtimeEnabled) { - parts.push( - realtimeConnected - ? colors.success('● realtime connected') - : colors.warning('○ realtime connecting…'), - ); + private buildStatusFooter(nextPollAt: null | number, quiet: boolean): string { + if (quiet) { + return ''; } - // The countdown to the next backstop poll is noise in quiet mode (geared at - // CI), so suppress it there while keeping the realtime indicator. - if (!quiet) { - if (nextPollAt === null) { - parts.push(colors.dim('refreshing…')); - } else { - const secondsLeft = Math.max(0, Math.ceil((nextPollAt - Date.now()) / 1000)); - parts.push(colors.dim(`next refresh in ${secondsLeft}s`)); - } + if (nextPollAt === null) { + return colors.dim('refreshing…'); } - return parts.join(colors.dim(' · ')); + const secondsLeft = Math.max(0, Math.ceil((nextPollAt - Date.now()) / 1000)); + return colors.dim(`next refresh in ${secondsLeft}s`); } } diff --git a/src/types/domain/auth.types.ts b/src/types/domain/auth.types.ts index 716029e..a6eab1b 100644 --- a/src/types/domain/auth.types.ts +++ b/src/types/domain/auth.types.ts @@ -8,8 +8,8 @@ export interface AuthContext { headers: Record; mode: 'apiKey' | 'bearer'; /** - * Supabase JWT — present when mode === 'bearer'. Lets realtime subscriptions - * authenticate the socket (RLS) without re-reading the session from disk. + * Supabase JWT — present when mode === 'bearer'. Kept beside the headers so + * a refresh can swap it without re-reading the session from disk. */ accessToken?: string; /** Environment the session belongs to — present when mode === 'bearer'. */ diff --git a/test/unit/results-poll-cache.test.ts b/test/unit/results-poll-cache.test.ts index e24a981..8fca80a 100644 --- a/test/unit/results-poll-cache.test.ts +++ b/test/unit/results-poll-cache.test.ts @@ -192,7 +192,7 @@ describe('results poll: summary view and ETag revalidation', () => { ); const service = new ResultsPollingService(); // Poll back to back instead of every 20s. - (service as unknown as { APIKEY_POLL_INTERVAL_MS: number }).APIKEY_POLL_INTERVAL_MS = 0; + (service as unknown as { POLL_INTERVAL_MS: number }).POLL_INTERVAL_MS = 0; const logs: string[] = []; const result = await service.pollUntilComplete({ diff --git a/test/unit/session-refresh.test.ts b/test/unit/session-refresh.test.ts index a0cf242..dc468fa 100644 --- a/test/unit/session-refresh.test.ts +++ b/test/unit/session-refresh.test.ts @@ -8,7 +8,6 @@ import { CliAuthGateway, SessionRefreshError, } from '../../src/gateways/cli-auth-gateway.js'; -import { RealtimeResultsGateway } from '../../src/gateways/realtime-gateway.js'; import { clearContextCache, getContext } from '../../src/mcp/context.js'; import { ReportDownloadService } from '../../src/services/report-download.service.js'; import { @@ -34,7 +33,6 @@ const ORIGINAL_ENV = { ...process.env }; const realNow = Date.now; const realRefresh = CliAuthGateway.refresh; const realGetResults = ApiGateway.getResultsForUpload; -const realSubscribe = RealtimeResultsGateway.subscribe; const realFetch = (global as any).fetch; const nowSeconds = () => Math.floor(Date.now() / 1000); @@ -97,7 +95,6 @@ describe('session refresh for long-running processes', () => { Date.now = realNow; CliAuthGateway.refresh = realRefresh; ApiGateway.getResultsForUpload = realGetResults; - RealtimeResultsGateway.subscribe = realSubscribe; (global as any).fetch = realFetch; clearContextCache(); process.env = { ...ORIGINAL_ENV }; @@ -250,22 +247,6 @@ describe('session refresh for long-running processes', () => { return seen; } - /** Stand in for the Supabase socket and record the tokens it is handed. */ - function stubRealtime(): { joinedWith: string[]; updatedTo: string[] } { - const calls = { joinedWith: [] as string[], updatedTo: [] as string[] }; - RealtimeResultsGateway.subscribe = (options) => { - calls.joinedWith.push(options.accessToken); - return { - isConnected: () => false, - async unsubscribe() {}, - updateAccessToken(token: string) { - calls.updatedTo.push(token); - }, - }; - }; - return calls; - } - const poll = (auth: AuthContext, service = new ResultsPollingService()) => service.pollUntilComplete({ auth, @@ -275,10 +256,9 @@ describe('session refresh for long-running processes', () => { uploadId: 'u1', }); - it('polls with a refreshed token, and hands it to the realtime socket', async () => { + it('polls with a refreshed token', async () => { storeSession('fresh', 3600, '99'); const seen = stubResults(); - const realtime = stubRealtime(); const result = await poll(expiredBearer('stale', '42')); @@ -287,8 +267,6 @@ describe('session refresh for long-running processes', () => { // identity headers (dcd#1622), which this test is not about. expect(seen).to.have.length(1); expect(seen[0]).to.include({ authorization: 'Bearer fresh', 'x-dcd-org': '42' }); - expect(realtime.joinedWith).to.deep.equal(['stale']); - expect(realtime.updatedTo).to.deep.equal(['fresh']); }); it('leaves API-key polling exactly as it was', async () => { @@ -299,7 +277,6 @@ describe('session refresh for long-running processes', () => { it('retries a refresh that failed on a network blip, like any failed poll', async () => { storeSession('stale', 10); - stubRealtime(); const seen = stubResults(); let attempts = 0; CliAuthGateway.refresh = async () => { @@ -326,7 +303,6 @@ describe('session refresh for long-running processes', () => { it('stops at once, with a reconnect hint, when only `dcd login` can help', async () => { storeSession('stale', 10); - stubRealtime(); const seen = stubResults(); CliAuthGateway.refresh = async () => { throw new SessionRefreshError( @@ -357,7 +333,6 @@ describe('session refresh for long-running processes', () => { it('leads with the expiry when the session passed its limit', async () => { storeSession('stale', 10); - stubRealtime(); stubResults(); CliAuthGateway.refresh = async () => { throw new SessionRefreshError(