@vercel/functions 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @vercel/functions
2
2
 
3
+ ## 2.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Update runtime cache to always use the current cache instance to prevent holding a stale copy ([#13454](https://github.com/vercel/vercel/pull/13454))
8
+
3
9
  ## 2.2.0
4
10
 
5
11
  ### Minor Changes
package/cache/index.js CHANGED
@@ -33,15 +33,15 @@ const defaultKeyHashFunction = (key) => {
33
33
  const defaultNamespaceSeparator = "$";
34
34
  let inMemoryCacheInstance = null;
35
35
  const getCache = (cacheOptions) => {
36
- let cache;
37
- if ((0, import_get_context.getContext)().cache) {
38
- cache = (0, import_get_context.getContext)().cache;
39
- } else {
36
+ const resolveCache = () => {
37
+ const ctxCache = (0, import_get_context.getContext)().cache;
38
+ if (ctxCache)
39
+ return ctxCache;
40
40
  if (!inMemoryCacheInstance) {
41
41
  inMemoryCacheInstance = new import_in_memory_cache.InMemoryCache();
42
42
  }
43
- cache = inMemoryCacheInstance;
44
- }
43
+ return inMemoryCacheInstance;
44
+ };
45
45
  const hashFunction = cacheOptions?.keyHashFunction || defaultKeyHashFunction;
46
46
  const makeKey = (key) => {
47
47
  let prefix = "";
@@ -53,16 +53,16 @@ const getCache = (cacheOptions) => {
53
53
  };
54
54
  return {
55
55
  get: (key, options) => {
56
- return cache.get(makeKey(key), options);
56
+ return resolveCache().get(makeKey(key), options);
57
57
  },
58
58
  set: (key, value, options) => {
59
- return cache.set(makeKey(key), value, options);
59
+ return resolveCache().set(makeKey(key), value, options);
60
60
  },
61
61
  delete: (key) => {
62
- return cache.delete(makeKey(key));
62
+ return resolveCache().delete(makeKey(key));
63
63
  },
64
64
  expireTag: (tag) => {
65
- return cache.expireTag(tag);
65
+ return resolveCache().expireTag(tag);
66
66
  }
67
67
  };
68
68
  };
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  "require": "./middleware.js"
27
27
  }
28
28
  },
29
- "version": "2.2.0",
29
+ "version": "2.2.1",
30
30
  "repository": {
31
31
  "directory": "packages/functions",
32
32
  "type": "git",