Skip to content

Commit adc4a89

Browse files
committed
fix: prevent TypeError in serialize_refreshes when state.refreshes is null
Fixes issue where remote function redirects would crash with 'TypeError: Cannot convert undefined or null to object' when calling Object.keys() on undefined state.refreshes. This happens when redirect() is called in remote functions and serialize_refreshes tries to process refresh data that doesn't exist. The fix adds a fallback to an empty object when state.refreshes is null/undefined.
1 parent e6c3171 commit adc4a89

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ async function handle_remote_call_internal(event, state, options, manifest, id)
194194
* @param {string[]} client_refreshes
195195
*/
196196
async function serialize_refreshes(client_refreshes) {
197-
const refreshes = /** @type {Record<string, Promise<any>>} */ (state.refreshes);
197+
const refreshes = /** @type {Record<string, Promise<any>>} */ (state.refreshes || {});
198198

199199
for (const key of client_refreshes) {
200200
if (refreshes[key] !== undefined) continue;

0 commit comments

Comments
 (0)