Skip to content

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

Merged
luismeyer merged 9 commits into
codex/flags-header-sourcefrom
codex/flags-client-debug
Oct 9, 2026
Merged

luismeyer merged 9 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 9, 2026 1:08pm UTC
flags-sdk-dev Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
flags-sdk-flagsmith Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
flags-sdk-growthbook Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
flags-sdk-launchdarkly Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
flags-sdk-openfeature Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
flags-sdk-posthog Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
flags-sdk-reflag Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
flags-sdk-snippets Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
flags-sdk-statsig Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
flags-sdk-sveltekit-snippets Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
shirt-shop Ready Ready Preview, v0 Oct 9, 2026 1:08pm UTC
shirt-shop-api Ready Ready Preview, v0 Oct 9, 2026 1:08pm 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 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
@vercel

vercel Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

You must have Developer access to commit code to Vercel Examples on Vercel. If you contact an administrator and receive Developer access, commit again to see your changes.

Learn more: https://vercel.com/docs/accounts/team-members-and-roles/access-roles#team-level-roles

luismeyer and others added 9 commits October 9, 2026 15:07
…ests

Parse DEBUG like the debug package (comma/space separated patterns,
wildcards, and - exclusions), cache the parse by raw value so disabled
calls stay cheap, and share the switch between client diagnostics and
the ingest debug header. Distinguish the fetch deadline from external
cancellation in datafile.fetch.aborted. Cover the redaction and
throwing-console guarantees through the public API.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WjWjQyvVvunuerU51GvB9M
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot mentioned this pull request Oct 9, 2026

This branch was successfully deployed

14 active deployments
Preview – flags-sdk-dev — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-sdk-sveltekit-snippets — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-playground — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-sdk-posthog — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-sdk-snippets — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-sdk-vercel — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-sdk-growthbook — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-sdk-flagsmith — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-sdk-statsig — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-sdk-launchdarkly — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-sdk-reflag — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – flags-sdk-openfeature — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – shirt-shop-api — 81ffcc87 Deployed Oct 9, 2026 by vercel[bot]
Preview – shirt-shop — 81ffcc87 Deployed Oct 9, 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.

3 participants