@vercel/functions 3.4.0 → 3.4.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 +8 -0
- package/cache/in-memory-cache.js +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @vercel/functions
|
|
2
2
|
|
|
3
|
+
## 3.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix InMemoryCache to use JSON serialization for consistency with RuntimeCache ([#14751](https://github.com/vercel/vercel/pull/14751))
|
|
8
|
+
|
|
9
|
+
InMemoryCache now serializes values with `JSON.stringify()` on set and deserializes with `JSON.parse()` on get, matching the behavior of RuntimeCache. This ensures consistent behavior when switching between cache implementations (e.g., in-memory for development, remote for production), particularly for types that don't survive JSON round-trips like `Date`, `Map`, `Set`, and `undefined`.
|
|
10
|
+
|
|
3
11
|
## 3.4.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/cache/in-memory-cache.js
CHANGED
|
@@ -32,13 +32,14 @@ class InMemoryCache {
|
|
|
32
32
|
await this.delete(key);
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
|
-
return entry.value;
|
|
35
|
+
return JSON.parse(entry.value);
|
|
36
36
|
}
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
async set(key, value, options) {
|
|
40
|
+
const serialized = JSON.stringify(value ?? null);
|
|
40
41
|
this.cache[key] = {
|
|
41
|
-
value,
|
|
42
|
+
value: serialized,
|
|
42
43
|
lastModified: Date.now(),
|
|
43
44
|
ttl: options?.ttl,
|
|
44
45
|
tags: new Set(options?.tags || [])
|