Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/server-functions-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,32 @@ export function TanStackServerFnPlugin(
const entryIdToFunctionId = new Map<string, string>()
const functionIds = new Set<string>()

function withTrailingSlash(path: string): string {
if (path[path.length - 1] !== '/') {
return `${path}/`
}
return path
}

const generateFunctionId: GenerateFunctionIdFn = ({
extractedFilename,
functionName,
filename,
}) => {
if (serverDevEnv) {
const root = serverDevEnv.config.root

let file = extractedFilename
if (extractedFilename.startsWith(withTrailingSlash(root))) {
file = extractedFilename.slice(root.length)
}
file = `/@id${file[0] === '/' ? '' : '/'}${file}`

const serverFn: {
file: string
export: string
} = {
file: extractedFilename,
file,
export: functionName,
}
const base64 = Buffer.from(JSON.stringify(serverFn), 'utf8').toString(
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export function getServerFnById() {}
export async function getServerFnById(): Promise<any> {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Missing required parameter in function signature.

The fake implementation is missing the id parameter that the real implementation includes (see packages/server-functions-plugin/src/index.ts lines 191 and 211). Even though this is a stub, the signature should match to maintain type consistency and prevent runtime errors if this fake is accidentally invoked.

Apply this diff to fix the signature:

-export async function getServerFnById(): Promise<any> {}
+export async function getServerFnById(id: string): Promise<any> {}

Additionally, consider tightening the return type from Promise<any> to be more specific if the actual return type is known.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function getServerFnById(): Promise<any> {}
export async function getServerFnById(id: string): Promise<any> {}
🤖 Prompt for AI Agents
In packages/start-server-core/src/fake-start-server-fn-manifest.ts around line
1, the exported async function is missing the required id parameter present in
the real implementation; update the function signature to accept the same id
parameter (and any other parameters that the real implementation defines at
lines 191 and 211 in packages/server-functions-plugin/src/index.ts) so the stub
matches the real API, and tighten the return type from Promise<any> to the
actual return type if known (or to a more specific union/interface) to maintain
type consistency and avoid runtime/typing surprises.

Loading