Skip to content

fix(docs): Mark the GET function callback as async #12750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

fix(docs): Mark the GET function callback as async #12750

wants to merge 1 commit into from

Conversation

sudheerkumarme
Copy link

☕️ Reasoning

The issue was that Next.js expects route handlers to return a Promise (i.e., work asynchronously). Without marking the function as async, TypeScript detects a mismatch where the expected parameter type (which relies on a Promise) doesn't align with a synchronous return value. Adding async ensures the function returns a Promise, resolving the type error.

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

📌 Resources

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
The issue was that Next.js expects route handlers to return a Promise (i.e., work asynchronously). Without marking the function as async, TypeScript detects a mismatch where the expected parameter type (which relies on a Promise) doesn't align with a synchronous return value. Adding async ensures the function returns a Promise, resolving the type error.

.next/types/app/api/user/route.ts:49:7 Type error: Type '{ tag: "GET"; param_position: "second"; param_type: AppRouteHandlerFnContext; }' does not satisfy the constraint 'ParamCheck<RouteContext>'. The types of 'param_type.params' are incompatible between these types. Type 'Record<string, string | string[]> | undefined' is not assignable to type 'Promise<any>'. Type 'undefined' is not assignable to type 'Promise<any>'.

47 | Diff< 48 | ParamCheck<RouteContext>,

49 | { | ^ 50 | tag: 'GET' 51 | param_position: 'second' 52 | param_type: SecondArg<MaybeField<TEntry, 'GET'>> Next.js build worker exited with code: 1 and signal: null
@sudheerkumarme sudheerkumarme requested a review from ndom91 as a code owner March 9, 2025 12:28
Copy link

vercel bot commented Mar 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 9, 2025 0:35am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Mar 9, 2025 0:35am

Copy link

vercel bot commented Mar 9, 2025

@sudheerkumarme is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@sudheerkumarme
Copy link
Author

Closing this request, I might have made a mistake!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant