-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Describe the bug
EdgeFeatureStore's incur significant overhead which slows down feature flag evaluations.
At the moment the @launchdarkly/js-server-sdk-common-edge
expects the bootstrap payload it receives from the feature store to be a string, which it then parses.
But some stores are already supply an object instead of a string.
These stores currently need to first call JSON.stringify
only for the @launchdarkly/js-server-sdk-common-edge
to then JSON.parse
that string into an object again.
JSON.stringify
and especially JSON.parse
are very slow operations.
For example, this leads to evaluating 70 feature flags taking over 150ms (excluding any network requests). After patching the issue this goes down to less than 20ms.
Details
The issue is that @launchdarkly/vercel-server-sdk has this line where it JSON.stringify’s the value read from our Edge Config store.
const edgeProvider: EdgeProvider = {
get: async (rootKey: string) => {
const json = await edgeConfig.get(rootKey);
return json ? JSON.stringify(json) : null;
},
};
It then later parses it again when calling deserializePoll
here, which internally calls tryParse
which then calls JSON.parse
.
Expected behavior
The @launchdarkly/js-server-sdk-common-edge
should accept a plain object instead of having to be passed a string.
SDK version
@launchdarkly/js-server-sdk-common-edge
2.6.8@launchdarkly/vercel-server-sdk
1.3.32
Language version, developer tools
TypeScript, JavaScript
OS/platform
Unrelated
Additional context
See the shared Slack channel you have with Vercel, where I posted about this as well.