( base: string, id: string, options: Omit<RequestInit, "body">, args: any[], )
| 66 | } |
| 67 | |
| 68 | async function fetchServerFunction( |
| 69 | base: string, |
| 70 | id: string, |
| 71 | options: Omit<RequestInit, "body">, |
| 72 | args: any[], |
| 73 | ) { |
| 74 | const instance = `server-fn:${INSTANCE++}`; |
| 75 | |
| 76 | const response = await initializeResponse(base, id, instance, options, args); |
| 77 | |
| 78 | if ( |
| 79 | response.headers.has("Location") || |
| 80 | response.headers.has("X-Revalidate") || |
| 81 | response.headers.has("X-Single-Flight") |
| 82 | ) { |
| 83 | if (response.body) { |
| 84 | /* @ts-ignore-next-line */ |
| 85 | response.customBody = async () => { |
| 86 | return await extractBody(instance, true, response.clone()); |
| 87 | }; |
| 88 | } |
| 89 | return response; |
| 90 | } |
| 91 | |
| 92 | const result = await extractBody(instance, true, response.clone()); |
| 93 | if (response.headers.has("X-Error")) { |
| 94 | throw result; |
| 95 | } |
| 96 | return result; |
| 97 | } |
| 98 | |
| 99 | export function cloneServerReference(id: string) { |
| 100 | let baseURL = import.meta.env.BASE_URL ?? "/"; |
no test coverage detected
searching dependent graphs…