Skip to content
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

Sveltekit vercel adapter ignores cron jobs #10071

Open
alexbjorlig opened this issue May 31, 2023 · 7 comments · Fixed by #10074
Open

Sveltekit vercel adapter ignores cron jobs #10071

alexbjorlig opened this issue May 31, 2023 · 7 comments · Fixed by #10074
Assignees
Labels
pkg:adapter-vercel Pertaining to the Vercel adapter

Comments

@alexbjorlig
Copy link
Contributor

Describe the bug

When using the vercel-adapter, cron jobs are ignored.

CleanShot 2023-05-31 at 20 35 56@2x

Reproduction

  • Open this stackblitz
  • Run the build script npm run build
  • Run cat .vercel/output/config.json - no cron jobs specified

Logs

No response

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.1.0 
    @sveltejs/adapter-vercel: ^3.0.0 => 3.0.0 
    @sveltejs/kit: ^1.5.0 => 1.20.0 
    svelte: ^3.54.0 => 3.59.1 
    vite: ^4.3.0 => 4.3.9

Severity

blocking an upgrade

Additional Information

There seems to also be a warning when building about the endpoint not being there, but it's there.

I might be missing something obvious, but I'm not sure what...

@elliott-with-the-longest-name-on-github
Copy link
Contributor

The warning in the build output is erroneous -- I'm about to push a fix. But the "not writing them to .vercel/output/config.json" is intended -- we don't need to copy them over; Vercel will pick them up from vercel.json. We only actually validate the paths at all as a courtesy. As long as they're in your vercel.json, they'll be published to your project when your site builds on Vercel.

@alexbjorlig
Copy link
Contributor Author

alexbjorlig commented Jun 1, 2023

The warning in the build output is erroneous -- I'm about to push a fix. But the "not writing them to .vercel/output/config.json" is intended -- we don't need to copy them over; Vercel will pick them up from vercel.json. We only actually validate the paths at all as a courtesy. As long as they're in your vercel.json, they'll be published to your project when your site builds on Vercel.

That might be true if using Vercel git integration, but we deploy with the vercel deploy --prebuilt, and in that case the CRON config is not working 😱

Fixed it with a small workaround, but would be amazing not having to do this

const vercelAsJson = JSON.parse(readFileSync('./vercel.json'));

const vercelConfig = JSON.parse(readFileSync('.vercel/output/config.json'));

const merged = { ...vercelConfig, ...vercelAsJson };

writeFileSync('.vercel/output/config.json', JSON.stringify(merged, null, 2));

process.exit(0);
 

@elliott-with-the-longest-name-on-github
Copy link
Contributor

but we deploy with the vercel deploy --prebuilt

Out of curiosity, why

@Rich-Harris

For users that aren't using the Git integration, could we expose a copyVercelJson config from @sveltejs/adapter-vercel? It could basically just do what he's doing above. Default to false since most users don't need it.

@alexbjorlig
Copy link
Contributor Author

Because Vercel does not have any tools built in for running db-migrations etc.

So to do that, the recommended way is to deploy from a github action (or similar) 🙃

@elliott-with-the-longest-name-on-github
Copy link
Contributor

Reopening to answer the above question

@Rich-Harris
Copy link
Member

Yeah, I use --prebuilt from time to time, especially if I'm testing unreleased libraries etc.

Do we need copyVercelJson? Is there any downside in just always copying the relevant parts?

@elliott-with-the-longest-name-on-github
Copy link
Contributor

Looks like only the crons key of vercel.json is valid in config.json. Maybe a more-targeted, less-likely-to-break solution is to only copy that key over if it's present. I'll open a PR for it.

@dummdidumm dummdidumm added the pkg:adapter-vercel Pertaining to the Vercel adapter label Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:adapter-vercel Pertaining to the Vercel adapter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants