-
Notifications
You must be signed in to change notification settings - Fork 30.6k
fix(unstable_cache): avoid undefined coercion in invocation cache key #91077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,7 +131,9 @@ export function unstable_cache<T extends Callback>( | |
| // Construct the complete cache key for this function invocation | ||
| // @TODO stringify is likely not safe here. We will coerce undefined to null which will make | ||
| // the keyspace smaller than the execution space | ||
| const invocationKey = `${fixedKey}-${JSON.stringify(args)}` | ||
| const invocationKey = `${fixedKey}-${JSON.stringify(args, (_, value) => | ||
| value === undefined ? '__undefined__' : value | ||
| )}` | ||
|
Comment on lines
+134
to
+136
|
||
| const cacheKey = await incrementalCache.generateCacheKey(invocationKey) | ||
| // $urlWithPath,$sortedQueryStringKeys,$hashOfEveryThingElse | ||
| const fetchUrl = `unstable_cache ${fetchUrlPrefix} ${cb.name ? ` ${cb.name}` : cacheKey}` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TODO comment about JSON.stringify coercing
undefinedtonullis now outdated with the new replacer. Please update this comment to reflect the current behavior (and/or the remaining known issues with using JSON.stringify for cache-key material).