fix: build errors for examples - #1553
Conversation
…nto ecklf/fix-build-errors
There was a problem hiding this comment.
Additional Suggestions:
req.cookies(aRequestCookiesobject) is passed wheregetPersonalizedRewriteexpects aRecord<string, string>, causing a TypeScript build failure.
apibuild fails withTS2307: Cannot find module '@repo/constants'because the workspace dependency is never built beforeapps/api'stscruns.
|
|
||
| const excludededPrefixes = ['/favicon', '/api'] | ||
|
|
||
| export function proxy(request: NextRequest) { |
There was a problem hiding this comment.
needs a config.matcher. getPersonalizedRewrite rewrites any pathname once the visitor has a builder.userAttributes.* cookie, and excludededPrefixes only covers /favicon and /api, so _next/static goes through it
same chunk url, with and without the cookie:
no cookie: 200 application/javascript 13809 bytes
with cookie: 200 text/html 1581 bytes
so every script and stylesheet breaks for personalized visitors. new behavior too - the old pages/_middleware.tsx was the next 12 convention, it never ran on 16
export const config = {
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
}think this is the only blocker, and CI won't catch it - build's green, the break is at runtime
| @@ -0,0 +1,5 @@ | |||
| { | |||
| "$schema": "https://openapi.vercel.sh/vercel.json", | |||
| "buildCommand": "cd ../.. && pnpm turbo build --filter=api", | |||
There was a problem hiding this comment.
works, but CI hasn't proven it - turborepo-hono-api and examples-q42o both say "Canceled by Ignored Build Step", so nothing built on this commit. the ignoreCommand I suggested is what's hiding it, sorry
ran it locally from apps/api and it's correct, constants builds then api. worth forcing one real build before merge though
nit: turborepo wants turbo run build when it's written into config or CI, bare turbo build is for interactive use. the sibling vercel.jsons do the same thing so no strong opinion
| const token = process.env.UPSTASH_REST_API_TOKEN | ||
| const url = process.env.KV_REST_API_URL | ||
| const token = | ||
| process.env.KV_REST_API_READ_ONLY_TOKEN ?? process.env.KV_REST_API_TOKEN |
There was a problem hiding this comment.
|| rather than ?? here I think - a dashboard var left blank comes through as "", not undefined, so it won't fall back. token ends up "" and you get Missing required KV REST API credentials instead of just using the write token
also the old protocol guard is gone, so a bare host in KV_REST_API_URL gives a generic fetch error now instead of the targeted one. readme shows the full https:// form so low risk
checked whether the write token gets baked into the edge bundle since this runs in middleware - it doesn't, process.env is preserved for runtime lookup. no issue, just noting it so nobody else goes looking. the build-writes / runtime-reads split is nice
| "baseUrl": ".", | ||
| "target": "es5", | ||
| "lib": ["dom", "dom.iterable", "esnext"], | ||
| "lib": [ |
There was a problem hiding this comment.
this reformat isn't prettier - --check passes on this file on main and fails now. one-key-per-line json is editor formatting, and the repo runs prettier over **/*.json via lint-staged
jsx: react-jsx and the next-env.d.ts change are real next 16 output though, a fresh build produces no further churn, so those should stay
cdn/mintlify-docs-rewrite/vercel.ts also fails the check - a pnpm prettier over both would clear it
Description
Fixes build failures surfaced while validating the Bun WebSocket example PR:
destination. Useroutes.rewrite()so dynamic destinations are emitted correctly.@vercel/global-configinitialized during module evaluation and failed when no connection string was available during the build. Create the client lazily when handling a request.POPULATE_REDIS=falseopt-out was treated as truthy. Compare the value explicitly so population can be disabled.@repo/constantsbecause the workspace dependency had not been built. Build it before compiling the API..svelte-kitbut omitted the adapter-generated.vercel/output, causing Vercel to report a missing output directory. Include.vercel/output/**in cached build outputs.Vercel project root settings were also corrected for the Services examples; their redeployments now pass.
Verification
pnpmbuilds locally.The Upstash deployment still depends on replacing or disabling its stale Redis endpoint.
Type of Change