Skip to content

Commit fa00cc3

Browse files
fix: regression when serializing server data (#13709)
* fix: regression when serializing server data * fix --------- Co-authored-by: Rich Harris <[email protected]>
1 parent 711d37a commit fa00cc3

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

.changeset/chilly-dancers-deliver.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: regression when serializing server data

packages/kit/src/runtime/server/data/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export function get_data_json(event, options, nodes) {
253253
return JSON.stringify(node);
254254
}
255255

256-
return `{"type":"data","data":${devalue.stringify(node.data, reducers)},${JSON.stringify(
256+
return `{"type":"data","data":${devalue.stringify(node.data, reducers)},"uses":${JSON.stringify(
257257
serialize_uses(node)
258258
)}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ''}}`;
259259
});
@@ -263,6 +263,8 @@ export function get_data_json(event, options, nodes) {
263263
chunks: count > 0 ? iterator : null
264264
};
265265
} catch (e) {
266+
// @ts-expect-error
267+
e.path = 'data' + e.path;
266268
throw new Error(clarify_devalue_error(event, /** @type {any} */ (e)));
267269
}
268270
}

packages/kit/src/runtime/server/page/render.js

+2
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,8 @@ function get_data(event, options, nodes, csp, global) {
658658
chunks: count > 0 ? iterator : null
659659
};
660660
} catch (e) {
661+
// @ts-expect-error
662+
e.path = e.path.slice(1);
661663
throw new Error(clarify_devalue_error(event, /** @type {any} */ (e)));
662664
}
663665
}

packages/kit/src/runtime/server/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export function redirect_response(status, location) {
133133
*/
134134
export function clarify_devalue_error(event, error) {
135135
if (error.path) {
136-
return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (data${error.path})`;
136+
return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path})`;
137137
}
138138

139139
if (error.path === '') {

0 commit comments

Comments
 (0)