Next.js `basePath`: queue-triggered flow route fails on Vercel with MODULE_NOT_FOUND `.next/server/pages/<basePath>/.well-known/workflow/v1/flow.js`

Đang mở
#4,971 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Lĩnh vực
backend, devops

Hướng nghiên cứu

Start by tracing how the Vercel build output and route table handle the workflow flow route when basePath is set; the issue names .next/server/app/.well-known/workflow/v1/flow/route.js, routes-manifest.json, and app-path-routes-manifest.json. Compare those entries with the failing launcher lookup under pages/admin/.well-known/workflow/v1/flow.js and the behavior without basePath. Done means queue deliveries reach the App Router handler on Vercel with basePath enabled.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

A Next.js app with basePath: "/admin" deploys to Vercel. Every queue delivery to the flow route fails before any user code runs, so no workflow run ever leaves queued. Runs started with start() are accepted, then retried every ~5 s forever.

This looks like the follow-up named in #2732: "the generated Vercel/Next output serves internal workflow invocation at /v2/.well-known/workflow/v1/flow, but [...] appears to be a Vercel/Next build-output route-table issue". #1864 reported the same error and was closed by #2732, but the platform part still reproduces on current versions. #3483 (also basePath: '/v2') may be the same defect seen from the queue side.

Versions

  • next 16.2.6 (App Router, Turbopack build)
  • workflow 5.2.2, @workflow/next 5.0.5, @workflow/core 5.2.2, @workflow/world-vercel 5.2.2, @vercel/queue 0.8.0
  • pnpm monorepo, app at apps/admin (launcher runs from /var/task/apps/admin)
  • Fluid compute, Node.js runtime, Pro team

Configuration

next.config.ts (simplified):

export default withWorkflow({
  basePath: "/admin",
  // ...
})

proxy.ts excludes the workflow routes, as the docs ask:

matcher: ["/", "/((?!\\.well-known/workflow/|_next/static|_next/image|favicon.ico).*)"]

What happens

The queue (User-Agent: vercel-queue/v2beta) sends POST /admin/.well-known/workflow/v1/flow. The function fails in ~8–23 ms with FUNCTION_INVOCATION_FAILED:

Failed to handle /admin/.well-known/workflow/v1/flow Error: Cannot find module './.next/server/pages/admin/.well-known/workflow/v1/flow.js'
Require stack:
- /var/task/apps/admin/___next_launcher.cjs
- /opt/rust/nodejs.js
  code: 'MODULE_NOT_FOUND'
  • Observability lists the route as /admin/.well-known/workflow/v1/flow (with the base path). Every other route in the same deployment is listed without it, e.g. /assistant.
  • The launcher looks under pages/ and includes the base path segment.
  • The build emits the handler as an App Router route: .next/server/app/.well-known/workflow/v1/flow/route.js. routes-manifest.json and app-path-routes-manifest.json list /.well-known/workflow/v1/flow.
  • app/.well-known/workflow/v1/config.json holds the queue/v2beta trigger for topic __wkf_workflow_*.

Expected

The queue trigger invokes the App Router handler at app/.well-known/workflow/v1/flow/route.js, as it does for an app without basePath.

Evidence

  • Deployment: dpl_CaToLKmeYmbxizgPPnDbv9guLFsL (production, branch main)
  • Workflow run: wrun_41M5EFC5JP90T9NVPKN8WSWW0X
  • Request ID: zjnrt-1792562314900-3ec8808307b5 (2026-10-21 05:58:34 UTC, sin1)

Questions

  1. Is there a supported way to run Workflow on Vercel with a Next.js basePath today?
  2. If not, is there a workaround that keeps basePath (the app is a Multi-Zones zone mounted at /admin)?
Ngôn ngữ chính
TypeScript
Star
2.5k
Fork
401
Merge trung bình
1 ngày 21 giờ
Pull request đã merge (30 ngày)
201

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của vercel/workflow

Tất cả issue của vercel/workflow

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.