add egg v4
Summary by CodeRabbit
-
Infrastructure Updates
- CI test matrix now includes Node.js 25.
-
New Features
- Added support for an additional runtime and a Koa v2 startup path with configurable runtime flags (framework, port, workers, reusePort, startMode).
- New profiling analysis tooling and an aggregated CPU profile report with optimization recommendations.
-
Tests
- Expanded local test orchestration to exercise multiple runtimes and improved per-service logging and cleanup.
✏️ Tip: You can customize this high-level summary in your review settings.
[!NOTE]
Other AI code review bot(s) detected
CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.
Walkthrough
Consolidates startup into a CLI-driven dispatcher (framework, port, workers, reusePort, startMode), adds Koa2 startup path and startKoa2(workers, port), updates run/test harness to launch multiple service variants with dedicated logs, changes package dependencies (egg4, koa2), and adds Node.js 25 to CI matrix.
Changes
| Cohort / File(s) | Summary |
|---|---|
CI Configuration \.github/workflows/nodejs\.yml |
Added Node.js 25 to the test matrix (now tests 20, 22, 24, 25). |
Package Configuration package\.json |
Replaced koa with alias koa2: "npm:koa@^2.13.4" and added alias egg4: "npm:egg@beta"; simplified test-simple script. |
Dispatcher & startup simple/dispatch.js, simple/start_koa2.js |
New CLI-driven dispatcher reads framework/port/workers/reusePort/startMode; routes koa2 to startKoa2(workers, port) or otherwise calls require(framework).startCluster(...). start_koa2.js forks workers in primary and starts Koa in workers. |
Koa server module simple/koa2.js |
Converted to exported startKoa2(port) (no top-level listen); uses the koa2 dependency alias and parameterized port. |
Run/test harness simple/run.sh |
Reworked to launch multiple service variants (koa2, multiple egg3 variants, egg4) with per-service log files and PIDs, added curl test targets for new ports, and updated cleanup to kill all spawned processes. |
Profiler tooling & reports profiler-egg-v4/... |
Added profiling analysis tools and docs: analyze-profile.js (ProfileAnalyzer), aggregate-profiles.js (AggregatedAnalyzer), and new reports AGGREGATED.md, REPORT.md, OPTIMIZATIONS.md. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant CLI as CLI (simple/dispatch.js)
participant Primary as Primary Process
participant Worker as Worker Process
participant KoaMod as simple/koa2.js
participant Framework as framework.startCluster
CLI->>Primary: invoke with (framework, port, workers, startMode, reusePort)
alt framework == "koa2"
Primary->>Primary: if primary -> fork N workers
Primary->>Worker: worker process starts (inherits args)
Worker->>KoaMod: require('./koa2') and call startKoa2(port)
KoaMod-->>Worker: listen on port
else other framework
Primary->>Framework: require(framework).startCluster({ startMode, workers, port, reusePort, ... })
Framework-->>Primary: framework handles cluster lifecycle
end
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
- Inspect concurrency and option handling in
simple/dispatch.js(startMode vs reusePort interactions). - Verify worker forking and port binding in
simple/start_koa2.jsandsimple/koa2.js. - Confirm
require(framework).startCluster(...)call shape and compatibility with theegg4alias. - Review
simple/run.shfor reliable PID tracking, log management, and port consistency.
Possibly related PRs
- eggjs/benchmark#22 — Modifies
simple/dispatch.jsandsimple/run.shto add/start additional server variants (reusePort and worker_threads); strongly related to the dispatcher/run orchestration changes here.
"I hopped through ports and pids with flair,
Spawned tiny servers in the morning air,
Twenty-five joined the parade,
Eggs and koa now warmly relayed,
A rabbit cheers — logs hum, tests prepare." 🐇✨
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'add egg v4' is concise and directly reflects the main purpose of the PR, which introduces Egg.js v4 support throughout the benchmark suite. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
egg-v4
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 @coderabbitai help to get the list of available commands and usage tips.
Summary of Changes
Hello @fengmk2, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces the latest beta version of the Egg.js framework, Egg.js v4, into the project's benchmarking suite. The changes involve updating dependencies, configuring the new framework for cluster-based execution, and modifying the benchmark script to include performance tests for Egg.js v4, while also adjusting the parameters for existing framework benchmarks to ensure consistency and potentially faster execution of the benchmark suite.
Highlights
- Egg.js v4 Integration: Egg.js version 4 (beta) has been added as a new dependency and integrated into the benchmarking setup.
-
Benchmarking Script Updates: The
simple/dispatch.jsscript now includesegg4cluster configurations, andsimple/run.shhas been updated to includeegg4in the benchmark tests. -
Benchmark Parameter Adjustments: Existing
wrkbenchmark tests foregg1,egg2,egg3, andkoahave had their duration reduced from 30 seconds to 10 seconds and thread count from 8 to 4. -
Node.js Cluster API Modernization: The
cluster.isMastercheck insimple/dispatch.jshas been updated tocluster.isPrimaryfor compatibility with newer Node.js versions.
Ignored Files
-
Ignored by pattern:
.github/workflows/**(1)- .github/workflows/nodejs.yml
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
| Diff | Package | Supply Chain Security |
Vulnerability | Quality | Maintenance | License |
|---|---|---|---|---|---|---|
| egg@4.1.0-beta.35 |