Repository navigation
@vercel/flags-core@1.10.0
Minor Changes
-
#511
3f925dcThanks @luismeyer! - Add a header-drivenvercelclient mode, enabled by default whenVERCEL=1. Initialization loads provided/bundled definitions. At module scope it starts no network activity, and an empty cache fetches on its first read. Inside a request,initialize()prepares the cache like the first evaluation would (confirm a matching version, fetch a newer one or an empty cache, or start streaming/polling for a missing entry), and repeated calls in later requests repeat that preparation. Request versions trigger refreshes. Explicit offline/build behavior is preserved.Evaluations require a valid positive version header for their own project. Missing, empty, malformed, or unrelated project entries permanently start streaming when enabled, otherwise polling; multiple clients select their sources independently. Concurrent reads share startup and pending HTTP refreshes. Accepted stream updates and valid confirmations cancel superseded refreshes; waiting reads use the confirmed cache, and late responses cannot change cache or authorization state. A cold shared fetch discovers project identity before accepting header evidence; a failed cold fetch rejects without switching sources and is retried by the next read.
getDatafile()remains a snapshot that never starts streaming or polling: it serves cached definitions through the same header checks, stale-while-revalidate, blocking refresh, and stale-if-error, and loads bundled definitions or performs a one-time fetch when the cache is empty.Cached definitions now age in streaming and polling mode. Streaming data is fresh for 60 seconds after the last message; polling data is fresh for its interval plus the 10-second fetch deadline (40 seconds by default). Polling data then stays stale for
staleWhileRevalidateseconds (default 10) while reads refresh over HTTP in the background, and expired reads wait for the shared fetch. While streaming, reads never wait and no HTTP request competes with the connection: older data is served immediately and reported as stale while the stream's ping watchdog reconnects in the background, including right after a suspended runtime resumes. Data without a known age is served until its source first confirms it. Accepted updates, source responses, valid confirmations, and stream pings reset age without rewritingfetchedAt.Streaming and polling never run at the same time. A stream startup timeout or disconnect keeps the stream reconnecting in the background while reads serve the cache; polling starts only once the stream gives up for good (retries exhausted, 401, or token failure), waiting for its first poll up to
polling.initTimeoutMs. Ping timeouts reconnect the stream internally, allowing suspended runtimes to resume. Polling gives up on a 401 too. Whenever no live source is active, because the stream is reconnecting or the stream or polling gave up, reads apply plain stale-while-revalidate over HTTP: fresh withinstaleWhileRevalidate, served while refreshing in the background beyond that, and waiting for the refresh once older thanstaleWhileRevalidateplusstaleIfError; data of unknown age refreshes in the background. Shutting down and reinitializing a client rewires its sources and starts with a clean cache and failure deadline.Use
staleWhileRevalidate(default 10) andstaleIfError(default Infinity) in seconds, including fractions. Setting either to0disables its stale allowance. Datafiles preserve optionalfetchedAtepoch-millisecond timestamps across serialization and bundled/provided reuse. -
#540
1a38deeThanks @vincent-derks! - Remove the internalprojectIdconnection string option introduced in 1.9.0. SDK keys andsdkKey=connection strings are unchanged. -
#510
571141dThanks @luismeyer! - AddstaleIfErrorin seconds to bound cached runtime reads after the first consecutive stream/poll failure or stream disconnect. The defaultInfinitypreserves unlimited fallback; finite nonnegative durations (including fractional seconds) use existing evaluation defaults and errors after expiry, andgetDatafile()follows the same allowance. Any successful source response resets the allowance, including one the version guard rejects as older or for a different project, as does a matching stream primed revision. Storing provided or bundled fallback data does not confirm freshness or renew the failure clock. Build/offline behavior and source scheduling remain unchanged.
Patch Changes
-
#518
941e71dThanks @luismeyer! - Add detailed client lifecycle, cache freshness, and network diagnostics using theDEBUG=@vercel/flags-coreenvironment variable.DEBUGnow follows the usual conventions for both the diagnostics and the ingest debug header: comma- or space-separated patterns,*wildcards, and-exclusions. A shared global logger emits events without passing logger instances through the client. Every client diagnostic includes the configuredclientName, including cache, source, and background network activity. Logs omit credentials, definitions, and raw errors.State changes include their cause; refresh logs distinguish response receipt, cache application, shared work, stream confirmation, and shutdown cancellation. Startup and source logs expose timeout and freshness thresholds, and recovery is logged only when a failure clears.
-
#511
3f925dcThanks @luismeyer! - RecordfetchedAtwhen a datafile fetch completes and preserve it in generated flag definitions. Loading the bundle retains the original timestamp so the Flags SDK can determine its age.Expose optional
fetchedAtmetadata on datafiles. Record it for accepted live updates and preserve valid timestamps when loading provided or bundled definitions, without mutating the input.