Skip to content

Run the monitor via a Vercel cron task#1745

Closed
yrong wants to merge 21 commits intomainfrom
ron/monitor-by-vercel
Closed

Run the monitor via a Vercel cron task#1745
yrong wants to merge 21 commits intomainfrom
ron/monitor-by-vercel

Conversation

@yrong
Copy link
Copy Markdown
Contributor

@yrong yrong commented Mar 12, 2026

Context

With this PR, we can run vercel --prod --archive=tgz to deploy the monitor to Vercel on demand.

It is currently deployed at https://vercel.com/snowfork/snowbridge-hyl7 and runs the monitor periodically every 15 minutes.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
snowbridge-hyl7 Error Error Mar 12, 2026 3:44pm

Request Review

@yrong yrong marked this pull request as ready for review March 13, 2026 03:36
@yrong yrong requested a review from Copilot March 13, 2026 03:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a Vercel Cron-driven deployment path for running the Snowbridge monitor on a schedule from the web/ workspace, including build-time Foundry installation and a serverless API entrypoint.

Changes:

  • Added Vercel configuration to deploy web/ with a cron schedule invoking /api/monitor every 15 minutes.
  • Added a Vercel serverless function (web/api/monitor.ts) that runs the existing operations monitor logic.
  • Added build/install scripting to ensure Foundry + contract type generation can run in Vercel builds, plus updated ignores and build scripts.

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
web/vercel.json Configures Vercel install/build commands, cron schedule, and function timeout.
web/api/monitor.ts Adds the serverless endpoint that invokes the operations monitor.
web/api/README.md Documents the cron endpoint, auth expectations, and build requirements.
web/scripts/install-foundry.sh Installs Foundry from GitHub releases and installs/builds forge deps.
web/package.json Adds Vercel-specific build scripts and dependencies needed for the serverless deployment.
web/packages/contract-types/scripts/build.sh Adds a build wrapper to support environments with/without Foundry.
web/packages/contract-types/package.json Switches build to the new script and keeps a full build option.
web/.vercelignore Reduces uploaded deployment size for the web/ root directory.
.vercelignore Adds repo-wide ignore rules to reduce deployment size when deploying from repo root.
web/.gitignore Ignores .vercel and the local Foundry install directory under web/scripts.
.gitignore Ignores .vercel at the repo root.
web/pnpm-lock.yaml Captures dependency graph updates (notably Vercel runtime tooling deps).
Files not reviewed (1)
  • web/pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web/api/monitor.ts Outdated
Comment thread web/package.json
Comment thread web/package.json Outdated
Comment thread web/scripts/install-foundry.sh Outdated
Comment thread web/scripts/install-foundry.sh Outdated
Comment thread web/api/README.md Outdated
Comment thread web/api/README.md Outdated
yrong and others added 6 commits March 13, 2026 14:22
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread web/api/monitor.ts Outdated
console.error("Monitor error:", error);
return res.status(500).json({
error: "Monitor failed",
message: error instanceof Error ? error.message : String(error),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should remove the error message here, it could expose RPC URLs, AWS details, or stack traces to unauthenticated callers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread web/api/monitor.ts Outdated

const authHeader = req.headers.authorization;
if (
process.env.CRON_SECRET &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Auth bypass when CRON_SECRET is unset. If process.env.CRON_SECRET is falsy, the auth check is skipped entirely. This means anyone can hit /api/monitor and trigger a full monitor run (hitting all RPCs, sending CloudWatch metrics). Should fail closed - reject if CRON_SECRET is not configured, at least in production.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread web/package.json
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"build": "turbo run build --concurrency=1 --no-cache",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is --no-cache removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Otherwise, the Vercel build process will fail. I can't find the detailed error messages right now, but there are also some warning messages in my local setup, which suggest that this option parameter may be deprecated.

(base) ➜  web git:(ron/monitor-by-vercel) pnpm build
> @snowbridge/web@ build /Users/yangrong/Projects/snowbridge/web
> turbo run build --concurrency=1 --no-cache
 WARNING  --no-cache is deprecated and will be removed in a future major version. Use --cache=local:r,remote:r

Comment thread web/package.json Outdated
"pino-pretty": "^13.1.1"
},
"devDependencies": {
"@types/pino": "^7.0.5",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@types/pino v7 is outdated and may conflict. Pino 10.x ships its own types - this dep is probably unnecessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread web/scripts/install-foundry.sh Outdated
@yrong yrong closed this Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants