[FIX] Vercel Deploy
This PR fixes the Vercel deploy by using the internal playwright packaged used in Vercel VMs
Added new packages:
playwright-core@sparticuz/chromium
Removed:
- conflicting npm lock-file
Edited:
- Dev vs Vercel deploy environments
- User agent in prod
https://github.com/user-attachments/assets/37902dd3-21fc-4b5b-9b7c-efa212200212
@artokun is attempting to deploy a commit to the Linkly AI LLC's projects Team on Vercel.
A member of the Team first needs to authorize it.
Closes https://github.com/gcui-art/suno-api/issues/226
When trying out the fix on Vercel with an actual API call that is launching the browser, I get the following error:
Error generating custom audio: Error: The input directory "/var/task/.next/server/bin" does not exist.
at Chromium.executablePath (/var/task/.next/server/chunks/279.js:87115:19)
at SunoApi.launchBrowser (/var/task/.next/server/chunks/57.js:299:114)
at SunoApi.getCaptcha (/var/task/.next/server/chunks/57.js:338:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SunoApi.generateSongs (/var/task/.next/server/chunks/57.js:543:20)
at async SunoApi.custom_generate (/var/task/.next/server/chunks/57.js:514:24)
at async POST (/var/task/.next/server/app/api/custom_generate/route.js:314:31)
at async /var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:42484
at async eI.execute (/var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:32486)
at async eI.handle (/var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:43737)
Ah ok, let me take that for a spin then. might be a quick fix actually
@jonico So I didn't have any issues myself on a live vercel deployment. Give this a try? (i'll keep the link live for 1 day, please don't abuse it ((too much π ))
curl --location 'suno-api-sigma-smoky.vercel.app/api/generate' \
--header 'Content-Type: application/json' \
--data '{
"prompt": "A popular heavy metal song about war, sung by a deep-voiced male singer, slowly and melodiously. The lyrics depict the sorrow of people after the war.",
"make_instrumental": false,
"model": "chirp-v4",
"wait_audio": false
}'
@jonico @blueeon what's the endpoint you guys were having trouble with? I can fix for that specific route if it's failing. I tested a handful of routes without issues. Also share what non-default ENVs you're using that are generic (non private key obvs)
Are you sure that with the playwright-core package no 'fake app' songs are being generated? I had to switch to rebrowser-patches to fix this.
@artokun just tested with your Vercel instance and got the same error:
Hi, same for me. Both /custom_generate and /generate endpoints are also throwing the error:
{ "error": "Error: The input directory "/var/task/.next/server/bin" does not exist." }
I have tried both BROWSER_HEADLESS=true and BROWSER_HEADLESS=false. The rest non sensitive env vars:
BROWSER_LOCALE=en BROWSER_GHOST_CURSOR=false BROWSER=chromium
Can you verify your build and env settings in Vercel? This is very bizzare, it's like it's not building or it using cached artifacts
I see custom_generate is indeed throwing an issue, investigating
All default, I have changed nothing there:
I have tested 4 endpoints:
- get_limit & generate_lyrics OK
- custom_generate & generate KO: { "error": "Error: The input directory "/var/task/.next/server/bin" does not exist." }
Took a hot minute but I got it working with vercel, @gohoski you were right, it was making the fake app, but now it's making real songs with the package you introduced originally.
Generated Audio File https://audiopipe.suno.ai/?item_id=6fb10694-1ff4-4a1e-9b55-21c8da95c696
Thanks for the fixes. I'm not getting that error anymore, but a vercel timeout. I had to change maxDuration to 60 in both src/app/api/custom_generate/route.ts and src/app/api/generate/route.ts because otherwise vercel throws an error (hobby/free tier maximum max time for serverless functions is 60 secs, https://vercel.com/docs/functions/runtimes#max-duration). I guess 60 secs is not enough at all, even if "wait_audio": false. I don't know if there could be a workaround by leveraging vercel's edge functions for generate and custom_generate, which are the most time consuming I think:
"Functions using the Edge runtime do not have a maximum duration. They must begin sending a response within 25 seconds and can continue streaming a response beyond that time."
@artokun π Looks good, but please fix the npm package files to install rebrowser. Also, for a local deploy, it seems that we will install two browsersβfirst the @Sparticuz/chromium, then the original Playwright one. Is there any way to fix this and make it so @Sparticuz/chromium would be installed only for Vercel? Maybe we can use the @Sparticuz/chromium-min package.
@maindconsultingservices To fix this, maybe we can develop a task system or a webhook as described in #228.
Alright. I was able to:
- Get it working with Docker + Local without worrying about any external packages when not in a vercel environment
- Get it working inside a Vercel Deployment environment
I was NOT able to:
- Not include the precompiled sparticuz package as a direct dependency, while it does add an extra 20mb to the package, I can't seem to load it conditionally and have it still work, it has to do with how it collects the path after installation most likely.
Let me know if there is anything else you'd like to see, otherwise I think I reached my wits end on how to get this to work accross all environments
@artokun π Looks good, but please fix the npm package files to install rebrowser. Also, for a local deploy, it seems that we will install two browsersβfirst the @Sparticuz/chromium, then the original Playwright one. Is there any way to fix this and make it so @Sparticuz/chromium would be installed only for Vercel? Maybe we can use the @Sparticuz/chromium-min package.
@maindconsultingservices To fix this, maybe we can develop a task system or a webhook as described in #228.
Maybe we can land this PR then move to a streamable format using vercel's RSC streamable pattern
Is there any more feedback to get this PR in?
Seems to be good, but why did we suddenly move from npm to pnpm?
Seems to be good, but why did we suddenly move from
npmtopnpm?
There was a package.lock and a pnpm-lock in the repo, you can't have both so I deleted the npm one assuming the only reason the pnpm one was there was because it was desired. I can switch to the other no problem. Let me know if this is the case
pnpm hasn't been used here for like 8 months, so I doubt that blueeon has plans on moving to pnpm. I didn't know that you can't have both though, thanks for letting me know.
Right now I don't see any definite advantages of pnpm over other package managers. Right now npm serves everything we need, if we will have problems with it, then it will be reasonable to move. And we can actually just not move and run yarn/pnpm install.
What is being used on Vercel though? pnpm or npm?
What is being used on Vercel though? pnpm or npm?
At least when the pnpm update lock file is not up to date, Vercel complains about it not being up to date. I would recommend to test it out on vercel, it can be setup within minutes for free.
I'll revert to npm
Reverted back to NPM, deployed no issues on my end @gohoski
Reverted back to NPM, deployed no issues on my end @gohoski
Hi, I got this error message on build logs:
And this error on /api/custom_generate { "error": "Error: pOST: Executable doesn't exist at /home/sbx_user1051/.cache/ms-playwright/chromium_headless_shell-1148/chrome-linux/headless_shell\nβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\nβ Looks like Playwright Test or Playwright was just installed or updated. β\nβ Please run the following command to download new browsers: β\nβ β\nβ npx playwright install β\nβ β\nβ <3 Playwright Team β\nβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ" }
And this is my build setting:
I'm now on this crazy train too and happy to help debug and test. I've got my own fork of this stood up with this PR. Everything seems to be going well on the Playwright side so far but I'm hitting a timeout on the Suno front.
{
"error": "TimeoutError: pOST: Timeout 60000ms exceeded while waiting for event \"response\"\n=========================== logs ===========================\nwaiting for response \"**/api/project/**\\?**\"\n============================================================"
}
Reverted back to NPM, deployed no issues on my end @gohoski
Hi, I got this error message on build logs:
And this error on /api/custom_generate { "error": "Error: pOST: Executable doesn't exist at /home/sbx_user1051/.cache/ms-playwright/chromium_headless_shell-1148/chrome-linux/headless_shell\nβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\nβ Looks like Playwright Test or Playwright was just installed or updated. β\nβ Please run the following command to download new browsers: β\nβ β\nβ npx playwright install β\nβ β\nβ <3 Playwright Team β\nβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ" }
And this is my build setting:
Don't set anything in vercel, let it handle it on its own
I'm now on this crazy train too and happy to help debug and test. I've got my own fork of this stood up with this PR. Everything seems to be going well on the Playwright side so far but I'm hitting a timeout on the Suno front.
{ "error": "TimeoutError: pOST: Timeout 60000ms exceeded while waiting for event \"response\"\n=========================== logs ===========================\nwaiting for response \"**/api/project/**\\?**\"\n============================================================" }
- Captcha won't get solved under 60s, usually for me it takes anywhere between 90s - 240s
- To get 300s timeout you need to be on a PRO Vercel account
See README section: https://github.com/gcui-art/suno-api/pull/227/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R132-R147
