diff --git a/packages/core/src/session.ts b/packages/core/src/session.ts index 24906cc5..605e6afe 100644 --- a/packages/core/src/session.ts +++ b/packages/core/src/session.ts @@ -139,6 +139,9 @@ export function defineAccessor(prototype: {}, name: string, keys: string[]) { return keys.reduce((data, key) => data?.[key], this) }, set(value) { + // Do not set undefined value + // See https://github.com/satorijs/satori/issues/166 + if (value === undefined) return const _keys = keys.slice() const last = _keys.pop() const data = _keys.reduce((data, key) => data[key] ??= {}, this)