Commit Graph

57 Commits

Author SHA1 Message Date
github-actions[bot] 0af37593bd Version Packages (#331)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-03-12 21:53:04 +02:00
nadav dd1396e461 Guard missing Vercel Flags runtime helpers (#326)
* Guard request-context flag reporting

* Preserve request-context hook binding

* Guard core request-context reporting

* Guard missing bundled flag definitions

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
2026-03-12 16:38:18 +02:00
github-actions[bot] e44eedf0cf Version Packages (#315)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-03-09 19:08:17 +02:00
Dominik Ferber df427e0e7a use catalog for react & react-dom (#318)
* use catalog for react & react-dom

this guarantees the same version for all packages and thus avoids type errors

* update lockfile
2026-03-09 19:01:30 +02:00
Dominik Ferber e5f3e34428 [docs] depend on workspace version of flags (#314)
* fix dep

* add packageManager

* move devDeps to top-level
2026-03-09 18:26:11 +02:00
Dominik Ferber 77727aaade use __no_flags__ to handle precompute with empty flags (#300)
* use __no_flags__ to handle precompute with empty flags

* handle __no_flags__ in serialize

* add __no_flags__ handling to sveltekit

* avoid returning undefined when defaultValue is set

This could only happen on precomputed flags in case of bad usage.

* add error messages

* test console logs

* update changeset
2026-03-09 15:10:47 +00:00
Dominik Ferber 2db1530275 Upgrade dependencies (#313)
* upgrade

* update biome

* upgrade more
2026-03-09 12:24:42 +00:00
github-actions[bot] 47806d4f89 Version Packages (#260)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-02-11 15:55:44 +02:00
Dominik Ferber 795dfd46a1 throw on declaration if flag is missing decide function (#259) 2026-02-09 13:28:41 +02:00
Dominik Ferber 53149f5e81 add client (#255)
* prepare

* origin

* prepare script

* step

* redo peer deps

* wip

* continue

* every 5 secs

* connect flag network

* add shirt-shop-vercel

* upgrade

* push

* update endpoint

* add vercel getProviderData

* fix importts

* Add retries to flag network datasource (#237)

* Fix React Server Components CVE vulnerabilities (#235)

Updated dependencies to fix Next.js and React CVE vulnerabilities.

The fix-react2shell-next tool automatically updated the following packages to their secure versions:
- next
- react-server-dom-webpack
- react-server-dom-parcel  
- react-server-dom-turbopack

All package.json files have been scanned and vulnerable versions have been patched to the correct fixed versions based on the official React advisory.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>

* Add retries to flag network datasource when stream closes

Implements automatic retry logic with exponential backoff when the flag network
stream unexpectedly closes. The stream will retry with delays increasing from
1s to a maximum of 30s, allowing the datasource to recover from temporary
network issues while falling back to bundled definitions if initial connection
fails.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* Revert package.json and pnpm-lock changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>

* use ndjson (#238)

* try

* try

* use debugLog

* replace testkey

* never retry on 4xx

* Track FLAG_CONFIG_READ events

* update @biomejs/biome

* send user-agent, rm terminate handling, fix tests

* extract usage-tracker and add tests

* rm EdgeConfigDataSource

* export EvaluationParams and EvaluationResult

* drop edge-config dep

* drop edge config from @flags-sdk/vercel

* adapt @flags-sdk/vercel

* fix integration tests

* wip

* assert ingest requests

* race initial connection, retry in background, abort on shutdown

* rm store

* make readBundledDefinitions async

* read from @vercel/flags-definitions/definitions.json

* add ensureFallback fn

* getDefaultFlagsClient() → flagsClient

* rm process.pid

* rm webpackIgnore: true

* require fallbacks at build time on vercel only

* test in layout

* vercel-flags prepare --verbose

* rm prebuild script

* ensure fallback from instrumentation.ts

* rm last process.pid

* print warning

* Track duration and cache status for config reads

* add tests

* await stream in initialize method

* consumeStream → runStreamLoop

* replace subscribe with doInitialize

* add webpackIgnore

* make @vercel/flags-core a peer dep

* fresh start

* debug

* step

* next-connection

* avoid opening stream during builds

* undo next specific exports

* handle abort

* fake

* poc

* clean up imports

* next-js exports

* upgrade next

* move "use cache" up

* move "use cache" handling to client

* split index.default.ts and index.next-js.ts

* separate

* jsdoc

* use scoped map instead of passing ref

* move jsdoc

* rename

* keep dataSource private, clean clientMap

* reset retryCount on connection; abort on 401

* break after 10 retries

* add backoff with jitter + limit

* add usage tracking and read fallback

* refactor

* extract stream-connection, update tests

* add tests

* reduce test amount

* add perf metadata

* add BaseEvaluationResult

* getData → read

* rm shirt-shop-vercel

* drop next-connection

* update pnpm-lock

* getMetadata → getInfo

* add getDatafile

* DataSourceData → Datafile

* merge metrics into datafile

* simplify metrics

* use embed for getDatafile

* add comment

* comment

* bring shirt-shop-vercel back

* try setCacheLife

* support cache components in OpenFeature import

* use new format

* rm cli

* fix origin

* use bundler

* simplify

* ensure warning is highlighted in build logs

* warn only once

* ensureFallback → getFallbackDatafile

* improve perf

* avoid creating new objects

* fix type issues

* stop exposing createRawClient

* fix: mark stream reconnection loop as intentional fire-and-forget

Add void operator before async IIFE to explicitly indicate the floating
promise is intentional, preventing linter warnings and making the code
intent clearer to future maintainers.

* fix: handle malformed JSON in stream messages gracefully

Wrap JSON.parse in try/catch to prevent crashes from malformed server
responses. Logs a warning and skips the invalid message instead of
crashing the stream connection handler.

* fix: add bounds checking for variant index access

Add getVariant() helper that throws a descriptive error if the variant
index is out of bounds. This prevents silent undefined returns when
variant indices are invalid, making issues easier to debug in production.

* fix: prevent concurrent initialization race condition

Add initializingPromise to coordinate concurrent initialize() calls.
The fast boolean check is preserved for the hot path, while concurrent
calls during initialization now await the same promise instead of
triggering multiple initializations.

* fix: add timeout and retry logic to fetchDatafile

- Add 10-second timeout using AbortController to prevent indefinite hangs
- Add exponential backoff retry (up to 3 attempts) for transient failures
- Skip retries for 4xx client errors (except 429 rate limiting)
- Improves resilience against network issues in production

* fix: prevent race condition in ensureStream

Use local variable for abortController and store streamPromise
immediately after creation. This prevents concurrent calls from
creating multiple streams or overwriting the abort controller
before the promise is stored.

* fix: prevent race condition in read() by capturing data reference

Capture this.data reference at the start of read() to ensure consistent
state throughout the method. The onMessage callback from the stream can
update this.data during async operations, which could cause inconsistent
behavior if the reference changes mid-operation.

* comments

* add streaming connectionState

* update usage

* fix init

* try to avoid hanging promise

* update attw, add types

* get rid of unnecessary async/await

* avoid printing the warning

* distinct warnings

* don't export cachedFns

* add CLAUDE.md

* jsdoc

* clear timeout

* export Datafile

* avoid exposing data sources

* simplify

* types

* avoid dangling timeout

* more options

* tests

* allow options in createClient

* DatafileInput

* better options

* Update event tracking to use streams

* Revert "Update event tracking to use streams"

This reverts commit cff740a18c.

* fix datafile input type

* type

* handle shutdown and re-init

* defensive

* retry stream for up to 15 minutes

* Update event reporting to use ndjson for more events

* Revert "Update event reporting to use ndjson for more events"

This reverts commit f70a7bfc59.

* Add debug logs to the usage tracker

* [adapter-vercel] fix getProviderData

* [adapter-vercel] only return vercel flags from getProviderData

* fix

* rm getInfo

* rm tgz

* rm example

* rm next/connection from gitignore

* rm unused deps

* use DatafileInput type

* fix tests

* ensure pollCount > 0

* fix type issues

* fix retry logic

* upgrade @sveltejs/kit

* resolve ci issues

---------

Co-authored-by: Luis Meyer <luis.meyer@vercel.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
2026-02-09 11:45:00 +02:00
Vincent Derks a1b77293c5 Updated tsup to 8.5.1 (#248) 2026-02-06 10:28:32 +01:00
dependabot[bot] 1d59ce11de Bump next from 16.0.10 to 16.1.5 in /packages/flags (#247)
* Bump next from 16.0.10 to 16.1.5 in /packages/flags

Bumps [next](https://github.com/vercel/next.js) from 16.0.10 to 16.1.5.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](https://github.com/vercel/next.js/compare/v16.0.10...v16.1.5)

---
updated-dependencies:
- dependency-name: next
  dependency-version: 16.1.5
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated lockfile

* Bump to 16.1.5 in other packages

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Vincent Derks <vincent.derks@vercel.com>
2026-02-06 10:07:56 +01:00
dependabot[bot] c571a329fa Bump vitest from 1.4.0 to 1.6.1 (#241)
* Bump vitest from 1.4.0 to 1.6.1

Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 1.4.0 to 1.6.1.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v1.6.1/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-version: 1.6.1
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated launchdarkly adapter vitest config to fix ESM directory import issues

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Vincent Derks <vincent.derks@vercel.com>
2026-02-06 08:55:26 +01:00
dependabot[bot] 564e494d71 Bump vite from 5.1.1 to 5.4.21 (#240)
* Bump vite from 5.1.1 to 5.4.21

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.1 to 5.4.21.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.4.21/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.4.21/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 5.4.21
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

* Trigger CI

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Vincent Derks <vincent.derks@vercel.com>
2026-02-05 13:52:10 +01:00
vercel[bot] 23cf50428e Fix React Server Components CVE vulnerabilities (#235)
Updated dependencies to fix Next.js and React CVE vulnerabilities.

The fix-react2shell-next tool automatically updated the following packages to their secure versions:
- next
- react-server-dom-webpack
- react-server-dom-parcel  
- react-server-dom-turbopack

All package.json files have been scanned and vulnerable versions have been patched to the correct fixed versions based on the official React advisory.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
2025-12-12 07:20:30 +02:00
Dominik Ferber ec0d13f66f Rename Edge Middleware to Routing Middleware / Proxy (#229)
* adjust proxy export

* rename Edge Middleware to Proxy

* mv folder

* rename featureFlagsInProxy

* proxy

* Routing Functions → Routing Middleware
2025-12-05 11:51:42 +02:00
Dominik Ferber 11472542d8 rename (#228) 2025-12-05 10:14:26 +02:00
Dominik Ferber f1376294aa upgrade (#226)
* upgrade

* use as-any workaround
2025-12-04 14:27:54 +02:00
github-actions[bot] b6f52d9f10 Version Packages (#214)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-11-06 17:18:43 +02:00
Dominik Ferber 5f3757afc7 stop relying on workspace tsconfig (#213)
* stop relying on workspace tsconfig

closes #204

* add changeset
2025-11-06 17:06:49 +02:00
Dominik Ferber f2eba9c624 upgrade pnpm (#198)
* extract @flags-sdk/utils

* init

* split package

* rename createFlagsClient to createClient

* add TODO

* wip

* add openfeature adapter

* reuse InlineDataSource

* fix type in test

* expose OpenFeature adapter

* implement OpenFeature adapter

* wip

* wip

* convert shirt-shop

* move store into flags-core

* split up data-source

* add READMEs

* upgrade to pnpm v10

* update comment

* undo example changes

* rm flags/utils

* fix biome issues

* rm status test

* tests
2025-10-25 00:13:34 +03:00
Dominik Ferber ba4eec7b23 replace eslint and prettier with biome (#187)
* remove @pyra/eslint-config

* wip

* wip

* convert shirt-shop-api

* convert shirt-shop

* convert snippets

* convert next-13

* convert next-14

* convert next-15

* eslint configs

* upgrade prettier

* use eslint v9

* run prettier

* resolve type-check

* adjust eslint

* drop Next.js v13

* fix next-14

Avoid accidentally using implicitly installed eslint v8

* update lockfile

* rm @eslint/eslintrc

* add @next/eslint-plugin-next

* biome

* biome fixes

* wip

* apply formatting

* tabs

* rm prettier

* spaces

* fix svelte

* update lockfile

* single quotes

* format all

* rm eslint-disable comments

* upgrade playwright

* upgrade publint

* upgrade playwright ci workflow

* try chromium headless

* try adding executablePath
2025-10-15 23:38:17 +03:00
github-actions[bot] 785ba56c7a Version Packages (#141)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-23 11:12:07 +03:00
Dominik Ferber d4108c8127 allow clearing the dedupe cache (#138)
* allow clearing the dedupe cache

* add changeset

* expose clearCacheForCurrentRequest

* reword changeset

* avoid adding prop to deduped fn
2025-05-23 11:07:58 +03:00
github-actions[bot] cd84279ce4 Version Packages (#127)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-02 17:48:11 +03:00
Dominik Ferber bc7944ed89 split crypto functions into dedicated functions (#126) 2025-05-02 17:45:00 +03:00
github-actions[bot] fcfc631db8 Version Packages (#109)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-03-21 14:50:36 +02:00
Simon H 701f3c2bf2 Sveltekit flags enhancements (#75)
* use `$env/dynamic/private` from SvelteKit for convenience: people don't have to pass FLAGS_SECRET manually anymore then

* allow flag to be called outside of the lifecycle of the handle hook, with a request object being the key for deduplication etc

* add support for identifiers

* fix types

* new function for managing precomputed flags

* align with next.js API instead

* update example app

* lockfile

* test

* fix example

* restructure examples app

* make it two flags to show power of precompute + code

* add manual approach

* lets see if preview deployment is picked up

* change crypto usage to be usable in middleware

* make sveltekit flags pkg usable within edge middleware

* use ISR

* changeset

* enhance error message

* use static env instead of dynamic env

* bump kit

* use vercel adapter

* make sure Vite tooling is used for sveltekit entry point

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
2025-03-21 14:43:28 +02:00
github-actions[bot] f427d868bc Version Packages (#108)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-03-19 17:47:39 +02:00
Andy b79a84a861 [flags] Add defaultValue to decide call (#107)
* [flags] Add `defaultValue` to `decide` call

* Update .changeset/popular-eels-heal.md

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
2025-03-19 17:30:13 +02:00
Andy 2fcc446ea8 Create LaunchDarkly adapter (#2)
* Create LaunchDarkly adapter

* Update example to include a LaunchDarkly flag

* Add missing env to turbo

* Rename to defaultLaunchDarklyAdapter

* Add winter sale example for providers

* Update winter-sale

* Document usage in readme

* Allow to set the default value through the adapter

* Fix readme

* Add default value for adapter

* Make argument optional

* Add @ts-expect-error

* Add a LaunchDarkly adapter (#10)

* add ld example

* reword

* remove winter-sale example

* remove defaultValue

* use @flags-sdk/launchdarkly

* add install steps

* add changeset

* move @vercel/edge-config to peer deps

* add more secrets

* spell out name

* remove unused env var

* rename properties

* Capitalize

* Change import

* Fix more imports

* expose ldClient

* move peerDeps to real deps

* clarify Edge Config requirement in README

* remove adapter-launchdarkly snippet

* upgrade next@canary

* polish @flags-sdk/launchdarkly README

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
2025-03-08 09:29:26 +02:00
Dominik Ferber f030fc5fdd flags-sdk.com » flags-sdk.dev (#71) 2025-02-21 08:26:50 +02:00
Dominik Ferber 422435c0eb rename (#68)
* @vercel-flags » flags

* update lockfile

* fix name
2025-02-20 19:54:09 +02:00
Andy 6a05c045f1 Fix import in README (#65) 2025-02-18 12:02:36 +02:00
github-actions[bot] cfad2444bf Version Packages (#60)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-02-14 13:43:03 -05:00
Aaron Morris cf532daf20 Update flags package json (#62)
* (flags) remove index from exports

* Update tsup.config, use clean:true instead of rimraf

* Add changeset

* pnpm-lock

* update tsup config, remove unused provider entrypoints

* tsup.config: update entry format

* Add attw check in CI

* Update .changeset/tidy-schools-retire.md

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
2025-02-14 09:45:24 +02:00
Dominik Ferber a96464e7b9 Revert "fix use node: protocol for async_hooks import (#52)"
This reverts commit 6784f10def.
2025-02-07 06:55:43 +02:00
Dominik Ferber 475dd26e4d remove empty line 2025-02-06 15:34:33 +02:00
jlca 6784f10def fix use node: protocol for async_hooks import (#52)
* fix use node: protocol for async_hooks import
2025-02-06 15:33:49 +02:00
Dominik Ferber 6955b68448 avoid printing full error during development (#59)
* avoid printing error in development

* add description

* add changeset

* change message

* add more tests
2025-02-05 17:55:25 +02:00
github-actions[bot] 1961a6a758 Version Packages (#48)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-01-24 17:45:35 +02:00
Dominik Ferber 2713ea7aff throw on undefined unless defaultValue is defined (#46)
* throw when decide returns undefined

* throw on undefined unless defaultValue is defined

* wip

* bring back JsonValue

* do not enforce on typescript level for now

* add changeset

* mention exported types

* add precise types

* fix summer-sale example
2025-01-24 14:22:12 +02:00
Dominik Ferber 76feb1667f add mergeProviderData (#47) 2025-01-23 19:57:31 +02:00
github-actions[bot] 051eb57ddc Version Packages (#41)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-01-21 14:21:46 +02:00
Dominik Ferber 13269ff404 add tests for inferred options (#42) 2025-01-20 21:35:21 +02:00
Dominik Ferber 708d5e21b9 infer options of boolean flags (#40)
* infer options of boolean flags

* fix typo
2025-01-20 17:34:04 +02:00
Dominik Ferber 55fe9b5e3c change from .com to .dev (#38) 2025-01-17 13:32:02 +02:00
github-actions[bot] 3b5ec2e887 Version Packages (#36)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-01-16 18:23:08 +02:00
Dominik Ferber 7e21d4f6be update README and package.json files (#35)
* update README

* add metadata to package.json

* add changeset

* add sveltekit keyword
2025-01-16 18:18:43 +02:00
github-actions[bot] 10f85c44b0 Version Packages (#3)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-01-16 16:53:56 +02:00