Skip to content

feat(flags-core): add opt-in client state debug logging - #518

Open
luismeyer wants to merge 6 commits into
codex/flags-header-sourcefrom
codex/flags-client-debug
Open

luismeyer wants to merge 6 commits into
codex/flags-header-sourcefrom
codex/flags-client-debug

Conversation

@luismeyer

@luismeyer luismeyer commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Stacked on #511 (codex/flags-header-source), including the unified polling initialization and source-assessment fixes.

Set DEBUG=@vercel/flags-core to follow the controller, shared cache, and network sources through one global console.debug logger. Every event includes the configured clientName so concurrent clients can be distinguished.

State transitions show the previous state, next state, and reason. Evaluation and getDatafile() events show project, revision, age, freshness assessment, and failure allowance. Refresh events distinguish background, blocking, and shared work; response receipt is separate from cache application. Stream-confirmed cancellation is distinguished from shutdown, and ordinary freshness confirmations do not look like outage recovery. Startup events expose timeout and freshness thresholds. HTTP retries and stream reconnects include attempt counts, delays, and reasons.

Source assessment failures log cache.source-error and header.fallback with reason source-assessment-error. Failed cold fetches propagate normally without claiming a source switch. Every polling transition logs start-polling and goes through polling initialization, including real stream disconnects.

Logging remains off by default, checks the namespace on each call, and computes details lazily. Diagnostics omit credentials, raw headers, definitions, evaluation entities, and raw error messages; a throwing console cannot interrupt client operations. The README includes an example trace and event guide. Event names and fields are internal diagnostics.

Validation: the rebased tree exactly matches the reviewed local implementation. All 1,012 core unit tests pass on Node 22 and Node 24; TypeScript, the core build, changed-file Biome, and diff checks pass. Regression coverage includes shared polling startup, stale-if-error at timeout, recovery from the stream while HTTP is pending, and shutdown cancellation without an unhandled rejection. Live-service integration tests were excluded.

@vercel

vercel Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
flags-playground Ready Ready Preview, v0 Oct 1, 2026 2:19pm UTC
flags-sdk-dev Ready Ready Preview, v0 Oct 1, 2026 2:19pm UTC
flags-sdk-snippets Ready Ready Preview, v0 Oct 1, 2026 2:19pm UTC
flags-sdk-sveltekit-snippets Ready Ready Preview, v0 Oct 1, 2026 2:19pm UTC
shirt-shop Ready Ready Preview, v0 Oct 1, 2026 2:19pm UTC
shirt-shop-api Ready Ready Preview, v0 Oct 1, 2026 2:19pm UTC

@luismeyer
luismeyer added this pull request to stack #512 September 23, 2026 13:34
@luismeyer
luismeyer force-pushed the codex/flags-client-debug branch from 09a8e94 to f50ca9f Compare September 30, 2026 14:56
@luismeyer
luismeyer force-pushed the codex/flags-client-debug branch from f50ca9f to 0768d43 Compare October 1, 2026 10:30
@luismeyer
luismeyer force-pushed the codex/flags-client-debug branch from 2dac318 to 76e3975 Compare October 1, 2026 10:54
@luismeyer
luismeyer force-pushed the codex/flags-client-debug branch from 76e3975 to 7abefe2 Compare October 1, 2026 11:00
@luismeyer
luismeyer force-pushed the codex/flags-client-debug branch from 7abefe2 to 4925dc8 Compare October 1, 2026 11:49

This branch was successfully deployed

6 active deployments
Preview – flags-sdk-dev — 61286163 Deployed Oct 1, 2026 by vercel[bot]
Preview – flags-sdk-sveltekit-snippets — 61286163 Deployed Oct 1, 2026 by vercel[bot]
Preview – flags-playground — 61286163 Deployed Oct 1, 2026 by vercel[bot]
Preview – flags-sdk-snippets — 61286163 Deployed Oct 1, 2026 by vercel[bot]
Preview – shirt-shop-api — 61286163 Deployed Oct 1, 2026 by vercel[bot]
Preview – shirt-shop — 61286163 Deployed Oct 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant