summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/silver-horses-beam.md5
-rw-r--r--packages/astro/src/actions/runtime/virtual/shared.ts29
2 files changed, 31 insertions, 3 deletions
diff --git a/.changeset/silver-horses-beam.md b/.changeset/silver-horses-beam.md
new file mode 100644
index 000000000..70a529fce
--- /dev/null
+++ b/.changeset/silver-horses-beam.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fixes an issue in the Astro actions, where the size of the generated cookie was exceeding the size permitted by the `Set-Cookie` header.
diff --git a/packages/astro/src/actions/runtime/virtual/shared.ts b/packages/astro/src/actions/runtime/virtual/shared.ts
index 57dc40449..00233bf41 100644
--- a/packages/astro/src/actions/runtime/virtual/shared.ts
+++ b/packages/astro/src/actions/runtime/virtual/shared.ts
@@ -213,14 +213,16 @@ export type SerializedActionResult =
export function serializeActionResult(res: SafeResult<any, any>): SerializedActionResult {
if (res.error) {
+ if (import.meta.env?.DEV) {
+ actionResultErrorStack.set(res.error.stack)
+ }
return {
type: 'error',
status: res.error.status,
contentType: 'application/json',
body: JSON.stringify({
...res.error,
- message: res.error.message,
- stack: import.meta.env.PROD ? undefined : res.error.stack,
+ message: res.error.message
}),
};
}
@@ -243,7 +245,15 @@ export function serializeActionResult(res: SafeResult<any, any>): SerializedActi
export function deserializeActionResult(res: SerializedActionResult): SafeResult<any, any> {
if (res.type === 'error') {
- return { error: ActionError.fromJson(JSON.parse(res.body)), data: undefined };
+ if (import.meta.env?.PROD) {
+ return { error: ActionError.fromJson(JSON.parse(res.body)), data: undefined };
+ } else {
+ const error = ActionError.fromJson(JSON.parse(res.body));
+ error.stack = actionResultErrorStack.get();
+ return {
+ error, data: undefined
+ }
+ }
}
if (res.type === 'empty') {
return { data: undefined, error: undefined };
@@ -255,3 +265,16 @@ export function deserializeActionResult(res: SerializedActionResult): SafeResult
error: undefined,
};
}
+
+// in-memory singleton to save the stack trace
+const actionResultErrorStack = function actionResultErrorStackFn() {
+ let errorStack: string | undefined;
+ return {
+ set(stack: string | undefined) {
+ errorStack = stack;
+ },
+ get() {
+ return errorStack;
+ }
+ }
+}();