Skip to content

Commit 72da53e

Browse files
committed
fix server fns handler
1 parent 86709a3 commit 72da53e

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/start/src/fns/handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getServerFnById } from "solidstart:server-fn-manifest";
21
import { parseSetCookie } from "cookie-es";
32
import { type H3Event, parseCookies } from "h3";
43
import { crossSerializeStream, fromJSON, getCrossReferenceHeader } from "seroval";
@@ -22,6 +21,7 @@ import { getFetchEvent, mergeResponseHeaders } from "../server/fetchEvent.ts";
2221
import { createPageEvent } from "../server/handler.ts";
2322
import type { FetchEvent, PageEvent } from "../server/types.ts";
2423
import { getExpectedRedirectStatus } from "../server/util.ts";
24+
import { getServerFunction } from "./manifest.ts";
2525

2626
function createChunk(data: string) {
2727
const encodeData = new TextEncoder().encode(data);
@@ -91,7 +91,7 @@ export async function handleServerFunction(h3Event: H3Event) {
9191
}
9292
}
9393

94-
const serverFunction = await getServerFnById(functionId!);
94+
const serverFunction = getServerFunction(functionId!);
9595

9696
let parsed: any[] = [];
9797

packages/start/src/fns/manifest.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export function registerServerFunction<T extends any[], R>(
1010

1111
export function getServerFunction<T extends any[], R>(
1212
id: string,
13-
): ((...args: T) => Promise<R>) | undefined {
14-
return REGISTRATIONS.get(id) as ((...args: T) => Promise<R>) | undefined;
13+
): ((...args: T) => Promise<R>) {
14+
const fn = REGISTRATIONS.get(id) as ((...args: T) => Promise<R>) | undefined;
15+
if (fn) {
16+
return fn;
17+
}
18+
throw new Error('invalid server function: ' + id);
1519
}

0 commit comments

Comments
 (0)