Repository navigation
fix(api): make every Vercel function return a response - #106
Merged
Merged
Conversation
Every function exporting `default async function handler(req)` was dead in production: Vercel's Node runtime ignores a Response returned from a default export, so the invocation hung until the 10s limit and returned FUNCTION_INVOCATION_TIMEOUT. That took down avatars, the YouTube info and thumbnail tools, AI title generation, Looney checks and account deletion, and the new /api/uptime.
All eight now use the shape already used by api/stats.js, api/track.js and api/music-link.js: a named handler plus `export default { fetch: handler }`. server.js imports the named handler for the local Express adapter.
|
@Coder-soft is attempting to deploy a commit to the yamura3's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 9
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a production bug where eight of the eleven
api/*.jsfunctions never returned.The bug
Vercel's Node.js runtime ignores a
Responsereturned from a default-exported function, so any handler written asexport default async function handler(req)never finished: the invocation hung until the function limit and the platform returnedFUNCTION_INVOCATION_TIMEOUT(504). The repository already documented this inapi/music-link.js:Only
api/stats.js,api/track.jsandapi/music-link.jsused that shape. Everything else was affected.Measured against the deployment directly (bypassing renderdragon.org, so Cloudflare is not involved):
GET /api/avatarGET /api/downloadThumbnailGET /api/uptimePOST /api/generateTitlesPOST /api/deleteAccountGET /api/downloadPOST /api/looney-checkGET /api/infoGET /api/stats(control)POST /api/track(control)So avatars, the YouTube info and thumbnail tools, AI title generation, Looney checks and account deletion were all broken for real users on the live site, independent of this branch.
The change
All eight files now use the working shape: a named
handlerexport plusexport default { fetch: handler }.server.jsimports the named handler, so the local Express adapter is unchanged in behaviour. No handler bodies were touched.Verified locally through the Express adapter:
/api/uptime200 with the full feed,/api/avatar?u=...200image/png,/api/avatarwithout params 400,/api/downloadThumbnail200 image,POST /api/generateTitlesresponds,POST /api/deleteAccount401,POST /api/looney-check400. ESLint clean.Note for review:
api/info.js,api/download.jsandapi/looney-check.jskeep theirexport const config = { runtime: 'nodejs' }. If Vercel rejects that combination with the{ fetch }default export, the fix is to drop theconfigblock, sinceapi/already defaults to the Node runtime.