Skip to content

fix(edgeone): discover Node functions before the project build - #101

Open
Alumos wants to merge 1 commit into
OpenListTeam:mainfrom
Alumos:fix/edgeone-function-discovery
Open

Alumos wants to merge 1 commit into
OpenListTeam:mainfrom
Alumos:fix/edgeone-function-discovery

Conversation

@Alumos

@Alumos Alumos commented Oct 3, 2026

Copy link
Copy Markdown

Summary / 摘要

On a fresh EdgeOne deployment, the frontend build can succeed while /api/public/env_check returns the SPA HTML and only the four KV proxy Edge Functions are deployed. The Node backend entry was generated during pnpm run build, after the CLI had already decided which function builders to enable.

  • Track a small cloud-functions/[[default]].js entry with an explicit onRequest export, so Node functions can be discovered before the project build.

  • Generate the actual backend bundle at dist-server/edgeone-entry.js. The entry imports that bundle, keeping generated code out of Git and preventing it from being registered as an additional function route.

  • Preserve the root catch-all to cover existing /api/*, download, WebDAV, S3 and SPA routes.

  • Update ignore rules, middleware documentation and Build Verify. CI checks that the tracked entry exists before building and tests JSON diagnostics and SPA responses through both the entry and a second bundle.

  • Remove an existing duplicate DbCipher type import that prevented pnpm run lint from passing.

  • This PR has breaking changes.

  • This PR changes public API, config, storage format, or migration behavior.

  • This PR requires corresponding changes in related repositories.

Related Issues / 关联 Issue

Relates to #93.

Testing / 测试

Validated locally with Node 22.21.1 and pnpm 9.15.4:

  • pnpm install --frozen-lockfile
  • node scripts/fetch-frontend.mjs and pnpm run build:edge
  • pnpm run lint
  • node --import tsx --test src/backend/server/*.test.ts — 175 passed.
  • node --test tests/edgeone-entry.test.mjs — 4 passed.
  • Prettier check for the changed build, entry, middleware, workflow and regression test files; git diff --check.
  • Official edgeone@1.6.41 CLI comparison using clean before/after snapshots: the original code completed its project build without producing a Node function; the fixed code produced .edgeone/cloud-functions/api-node/index.mjs with a single ^/(.*)$ route. Dependencies and official frontend assets were provided beforehand; the snapshot install command was a no-op and its build command was node scripts/build-edge.mjs.
  • Started the CLI-generated Node function locally and requested /api/public/env_check and /api/public/init_status: both returned HTTP 200 and JSON diagnostic data. This check intentionally had no production storage binding; it verifies the handler and diagnostics, not production storage readiness.

An EdgeOne production redeployment has not been performed. After redeploying, verify that the Node function appears and /api/public/env_check returns JSON before investigating storage availability.

Checklist / 检查清单

  • Read the linked CONTRIBUTING guidance.
  • Changes follow the existing repository license and contribution policies.
  • Formatted the changed JavaScript and workflow files with Prettier where applicable.
  • Requested a specific maintainer review.

AI Disclosure / AI 使用声明

  • This PR includes AI-assisted content.
  • Tool used: Codex.
  • Usage scope: implementation, regression tests, documentation, local verification and review assistance.
  • AI-assisted commits include Co-authored-by attribution.

The user supplied the deployment symptoms, logs and proposed discovery fix, and requested this contribution. Codex implemented and reviewed the changes and ran the validation above. Human code review remains pending.

Keep a tracked root handler so EdgeOne enables its Node function builder before
running the project build. Generate the backend bundle in dist-server and keep
it out of function discovery and version control.

Verify the entry before building and exercise diagnostics and SPA responses
after bundling. Remove a duplicate DbCipher type import that blocked lint.

Co-authored-by: Codex <noreply@openai.com>
ycbhk added a commit to ycbhk/OpenList-Worker that referenced this pull request Oct 4, 2026
EdgeOne CLI 在执行项目构建前就决定启用哪些函数构建器,而 Node 后端入口
(api/_makers.ts -> cloud-functions/[[default]].js) 原先由 pnpm run build 在
构建过程中生成;CLI 决策时它尚不存在,于是该 Node 函数从未被注册:前端构建
成功,但 /api/* 全部落到 SPA 兜底,只有 4 个 KV 边缘函数被部署。

本提交跟踪一个显式导出 onRequest 的入口文件,使 Node 函数能在构建前被发现;
实际后端包改由 dist-server/edgeone-entry.js 生成,避免被平台注册为额外路由。
对应上游 PR OpenListTeam#101。
ycbhk added a commit to ycbhk/OpenList-Worker that referenced this pull request Oct 4, 2026
EdgeOne CLI 在执行项目构建前就决定启用哪些函数构建器,而 Node 后端入口
(api/_makers.ts -> cloud-functions/[[default]].js) 原先由 pnpm run build 在
构建过程中生成;CLI 决策时它尚不存在,于是该 Node 函数从未被注册:前端构建
成功,但 /api/* 全部落到 SPA 兜底,只有 4 个 KV 边缘函数被部署。

本提交跟踪一个显式导出 onRequest 的入口文件,使 Node 函数能在构建前被发现;
实际后端包改由 dist-server/edgeone-entry.js 生成,避免被平台注册为额外路由。
对应上游 PR OpenListTeam#101。
ycbhk added a commit to ycbhk/OpenList-Worker that referenced this pull request Oct 4, 2026
EdgeOne CLI 在执行项目构建前就决定启用哪些函数构建器,而 Node 后端入口
(api/_makers.ts -> cloud-functions/[[default]].js) 原先由 pnpm run build 在
构建过程中生成;CLI 决策时它尚不存在,于是该 Node 函数从未被注册:前端构建
成功,但 /api/* 全部落到 SPA 兜底,只有 4 个 KV 边缘函数被部署。

本提交跟踪一个显式导出 onRequest 的入口文件,使 Node 函数能在构建前被发现;
实际后端包改由 dist-server/edgeone-entry.js 生成,避免被平台注册为额外路由。
对应上游 PR OpenListTeam#101。
ycbhk added a commit to ycbhk/OpenList-Worker that referenced this pull request Oct 4, 2026
EdgeOne CLI 在执行项目构建前就决定启用哪些函数构建器,而 Node 后端入口
(api/_makers.ts -> cloud-functions/[[default]].js) 原先由 pnpm run build 在
构建过程中生成;CLI 决策时它尚不存在,于是该 Node 函数从未被注册:前端构建
成功,但 /api/* 全部落到 SPA 兜底,只有 4 个 KV 边缘函数被部署。

本提交跟踪一个显式导出 onRequest 的入口文件,使 Node 函数能在构建前被发现;
实际后端包改由 dist-server/edgeone-entry.js 生成,避免被平台注册为额外路由。
对应上游 PR OpenListTeam#101。
ycbhk added a commit to ycbhk/OpenList-Worker that referenced this pull request Oct 4, 2026
EdgeOne CLI 在执行项目构建前就决定启用哪些函数构建器,而 Node 后端入口
(api/_makers.ts -> cloud-functions/[[default]].js) 原先由 pnpm run build 在
构建过程中生成;CLI 决策时它尚不存在,于是该 Node 函数从未被注册:前端构建
成功,但 /api/* 全部落到 SPA 兜底,只有 4 个 KV 边缘函数被部署。

本提交跟踪一个显式导出 onRequest 的入口文件,使 Node 函数能在构建前被发现;
实际后端包改由 dist-server/edgeone-entry.js 生成,避免被平台注册为额外路由。
对应上游 PR OpenListTeam#101。
ycbhk added a commit to ycbhk/OpenList-Worker that referenced this pull request Oct 4, 2026
EdgeOne CLI 在执行项目构建前就决定启用哪些函数构建器,而 Node 后端入口
(api/_makers.ts -> cloud-functions/[[default]].js) 原先由 pnpm run build 在
构建过程中生成;CLI 决策时它尚不存在,于是该 Node 函数从未被注册:前端构建
成功,但 /api/* 全部落到 SPA 兜底,只有 4 个 KV 边缘函数被部署。

本提交跟踪一个显式导出 onRequest 的入口文件,使 Node 函数能在构建前被发现;
实际后端包改由 dist-server/edgeone-entry.js 生成,避免被平台注册为额外路由。
对应上游 PR OpenListTeam#101。
ycbhk added a commit to ycbhk/OpenList-Worker that referenced this pull request Oct 4, 2026
EdgeOne CLI 在执行项目构建前就决定启用哪些函数构建器,而 Node 后端入口
(api/_makers.ts -> cloud-functions/[[default]].js) 原先由 pnpm run build 在
构建过程中生成;CLI 决策时它尚不存在,于是该 Node 函数从未被注册:前端构建
成功,但 /api/* 全部落到 SPA 兜底,只有 4 个 KV 边缘函数被部署。

本提交跟踪一个显式导出 onRequest 的入口文件,使 Node 函数能在构建前被发现;
实际后端包改由 dist-server/edgeone-entry.js 生成,避免被平台注册为额外路由。
对应上游 PR OpenListTeam#101。
ycbhk added a commit to ycbhk/OpenList-Worker that referenced this pull request Oct 4, 2026
EdgeOne CLI 在执行项目构建前就决定启用哪些函数构建器,而 Node 后端入口
(api/_makers.ts -> cloud-functions/[[default]].js) 原先由 pnpm run build 在
构建过程中生成;CLI 决策时它尚不存在,于是该 Node 函数从未被注册:前端构建
成功,但 /api/* 全部落到 SPA 兜底,只有 4 个 KV 边缘函数被部署。

本提交跟踪一个显式导出 onRequest 的入口文件,使 Node 函数能在构建前被发现;
实际后端包改由 dist-server/edgeone-entry.js 生成,避免被平台注册为额外路由。
对应上游 PR OpenListTeam#101。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants