feat(service-worker): standalone service worker runtime#6022
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a host-agnostic controller runtime, refactors Egg controller registration, and introduces standalone service-worker runtime and HTTP/MCP transports. It also adds ChangesStandalone service-worker controller
Estimated code review effort: 5 (Critical) | ~120 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying egg with
|
| Latest commit: |
3dc0448
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6247909c.egg-cci.pages.dev |
| Branch Preview URL: | https://feat-service-worker.egg-cci.pages.dev |
There was a problem hiding this comment.
Code Review
This pull request introduces standalone service worker support for @eggjs/tegg modules, allowing HTTP controllers and MCP tools to be served over a fetch event loop without requiring a full Egg application. It extracts the host-agnostic controller registration runtime into @eggjs/controller-runtime and adds the @eggjs/service-worker-runtime and @eggjs/service-worker packages, along with a runnable example. The review feedback suggests improving exception handling in FetchEventHandler by checking if caught errors are instances of Error before accessing their message, and expanding ResponseUtils to correctly handle and pass through standard web-standard BodyInit types (such as Uint8Array and Blob) instead of incorrectly serializing them as JSON.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Deploying egg-v3 with
|
| Latest commit: |
3dc0448
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://35abf8d4.egg-v3.pages.dev |
| Branch Preview URL: | https://feat-service-worker.egg-v3.pages.dev |
|
Dependency limit exceeded — report not shown. This pull request scan exceeded the 10,000-dependency limit applied to this scan, so the results are incomplete and may be inaccurate. To avoid reporting false positives, Socket has not posted a report. Upgrade your plan to raise the dependency limit and get complete reports, or view the partial scan in the dashboard. Socket is always free for open source. If this is a non-commercial open source project, contact us to request a free Team account. |
5001fb6 to
79594a6
Compare
bcb170d to
79d6bc3
Compare
b774e07 to
5c42a6d
Compare
79d6bc3 to
27cb9ef
Compare
85a0476 to
ad9acf9
Compare
9434e0b to
078a2d9
Compare
Summary
Adds a standalone service-worker host for running tegg HTTP controllers and MCP tools without starting an Egg application. The same controller metadata and registration core now serve both the Egg node-HTTP host and Fetch-compatible runtimes, with a runnable Node/Cloudflare example.
Architecture
@eggjs/controller-runtimeas the host-neutral controller library. Egg transport remains in@eggjs/controller-plugin; Fetch transport lives in@eggjs/service-worker-controller;@eggjs/service-workeris the host facade overStandaloneApp.@LoadUnitInstanceLifecycleProtoproviders whenCONTROLLER_LOAD_UNITis created; the Fetch host finalizes once while building routes on the first event.@Middleware(AdviceClass)form. The controller runtime invokesaround()at the bound HTTP/MCP invocation boundary and preservesAbstractControllerAdvice.middleware()compatibility, while explicit@Pointcutremains owned by the independent AOP plugin.EggMcpRouterinstead of writing to a static hook registry.Standalone runtime
serve(), embeddedhandleEvent(), and Cloudflare module-worker entries.Request/Response, parameter binding, binary and streaming bodies, multipleSet-Cookieheaders, request-scope stream draining, host-provided error mapping, and background tasks.TeggScopebag.Bundle and module loading
TeggManifestto the shared tegg type surface and uses the sharedManifestLoaderFSoverlay in both Egg and standalone hosts.ModuleLoader.createModuleLoader()retains the selected file view in the current app scope, so later dynamic loaders such as DAL discovery read manifest-indexed files in a bundle without expanding multi-instance callback context.egg-bin bundle, including TypeScript metadata scanning in a loader-enabled child process and Cloudflare-compatible worker output.main.tsis the Node entry andworker.tsis the Cloudflare entry.Validation
controller-runtime,controller-plugin,mcp-proxy-plugin, andservice-worker-controller.Documentation
Updates the service-worker, controller Advice, module-plugin lifecycle, LoaderFS/bundler, local CI, package README, and minimal-example documentation to match the final runtime contracts.