-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(tracer): merge tracer plugin into monorepo #5563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Merge @eggjs/tracer plugin from https://github.com/eggjs/tracer into monorepo at plugins/tracer/. Updated to version 4.0.0-beta.15 with standardized build configuration and dependencies. - Migrate from ESLint to oxlint for linting - Standardize with tsdown for unbundled builds - Update tests to use Vitest - Convert dependencies to workspace:* and catalog: - Add proper types.ts file for TypeScript support - Update all imports from @eggjs/core to egg 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Note Other AI code review bot(s) detectedCodeRabbit 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. WalkthroughAdds a new @eggjs/tracer plugin (source, config, types, package metadata, build/test configs), application/agent/context extensions and boot lifecycle, tests and fixtures exercising before/after readiness and HTTP trace propagation, and integrates the plugin into workspace, examples, and tooling. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Node as Node Process
participant App as Egg Application
participant Boot as TracerBoot
participant AppExt as TracerApplication (extension)
note over Node,App: App startup
Node->>App: create application
App->>Boot: new TracerBoot(app)
Boot-->>App: boot instance
App->>Boot: didLoad()
Boot->>AppExt: set app[isReady] = true
note over AppExt: readiness toggled → affects tracer caching behaviour
sequenceDiagram
autonumber
participant Client
participant Router
participant Ctx as TracerContext
participant Tracer as Tracer
Client->>Router: GET /
Router->>Ctx: handler(ctx)
alt ctx.tracer not created
Ctx->>Tracer: new Tracer(ctx)
Ctx->>Ctx: store TRACER
end
Ctx->>Tracer: get traceId (lazy randomUUID)
Tracer-->>Ctx: traceId
Ctx-->>Client: 200 OK + header x-trace-id
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60–90 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
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 |
Summary of ChangesHello @fengmk2, I'm Gemini Code Assist1! 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 integrates the Highlights
Using Gemini Code AssistThe 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
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 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 👍 and 👎 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. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR merges the standalone @eggjs/tracer plugin into the monorepo under the plugins/tracer/ directory. The migration involves standardizing the build and test configuration to align with the monorepo standards while updating the plugin to version 4.0.0-beta.15.
Key changes include:
- Migration from ESLint to oxlint for linting consistency
- Standardization with tsdown for unbundled builds and Vitest for testing
- Conversion of dependencies to workspace:* and catalog: patterns for centralized management
Reviewed Changes
Copilot reviewed 34 out of 37 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/create-egg/src/templates/tegg/package.json | Updates tracer dependency version from ^3.0.0 to beta for tegg template |
| plugins/tracer/package.json | Complete package configuration with monorepo-standard build tooling and dependencies |
| plugins/tracer/src/ | Core tracer implementation with TypeScript types, extensions for context/application/agent |
| plugins/tracer/test/ | Comprehensive test suite using Vitest with fixtures for different tracer configurations |
| plugins/tracer/README.md | Documentation for installation, usage, and custom tracer implementation |
| CLAUDE.md | Updates project documentation to include the new tracer plugin |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
|
|
||
| declare module 'egg' { | ||
| interface EggAppConfig { | ||
| tracer: TracerConfig; | ||
| } | ||
| } |
Copilot
AI
Sep 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate module declaration for EggAppConfig.tracer. This interface is already declared in src/types.ts lines 6-12. Consider removing this duplicate to avoid potential conflicts and maintain single source of truth.
| declare module 'egg' { | |
| interface EggAppConfig { | |
| tracer: TracerConfig; | |
| } | |
| } |
| @@ -0,0 +1,22 @@ | |||
| import type { TracerConfig } from './config/config.default.ts'; | |||
Copilot
AI
Sep 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circular import detected: types.ts imports TracerConfig from config.default.ts, but config.default.ts also declares module augmentation for the same types. Consider moving TracerConfig interface to types.ts to eliminate the circular dependency.
| import type { TracerConfig } from './config/config.default.ts'; | |
| // Moved TracerConfig interface definition here to avoid circular import | |
| export interface TracerConfig { | |
| // Define the properties of TracerConfig here. | |
| // Example: | |
| enabled: boolean; | |
| serviceName: string; | |
| // Add other config properties as needed | |
| } |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #5563 +/- ##
==========================================
+ Coverage 80.19% 80.29% +0.09%
==========================================
Files 201 205 +4
Lines 5660 5678 +18
Branches 833 834 +1
==========================================
+ Hits 4539 4559 +20
+ Misses 1048 1046 -2
Partials 73 73 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully merges the @eggjs/tracer plugin into the monorepo, updating it to use modern tooling like tsdown, vitest, and oxlint. The code is well-structured and the new implementation of the tracer using randomUUID is robust. I've left a few comments with suggestions to improve the documentation examples and test fixtures for better clarity and correctness. Overall, this is a great step towards standardizing the plugins within the Egg.js ecosystem.
| // my_tracer.js | ||
| const { Tracer } = require('@eggjs/tracer'); | ||
|
|
||
| const counter = 0; | ||
|
|
||
| class MyTracer extends Tracer { | ||
| get traceId() { | ||
| return `${counter++}-${Date.now()}-${process.pid}`; | ||
| } | ||
| } | ||
| module.exports = MyTracer; | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example for creating a custom tracer has a couple of issues that could mislead users:
- It uses CommonJS (
require,module.exports). Since this package is an ES module ("type": "module"), the example should use ESM syntax (import/export). - The
countervariable is declared at the module level. This means all instances ofMyTracerwill share the same counter, which can lead to non-uniquetraceIds in a concurrent environment. It would be safer to makecountera static property of the class.
| // my_tracer.js | |
| const { Tracer } = require('@eggjs/tracer'); | |
| const counter = 0; | |
| class MyTracer extends Tracer { | |
| get traceId() { | |
| return `${counter++}-${Date.now()}-${process.pid}`; | |
| } | |
| } | |
| module.exports = MyTracer; | |
| ``` | |
| // my_tracer.js | |
| import { Tracer } from '@eggjs/tracer'; | |
| class MyTracer extends Tracer { | |
| static #counter = 0; | |
| get traceId() { | |
| // This custom implementation is for demonstration only. | |
| // The default implementation using `randomUUID()` is more robust. | |
| return `${MyTracer.#counter++}-${Date.now()}-${process.pid}`; | |
| } | |
| } | |
| export default MyTracer; |
| // config/config.default.js | ||
| exports.tracer = { | ||
| Class: require('path/to/my_tracer.js'), | ||
| }; | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configuration example uses CommonJS syntax (exports.tracer, require). To align with the package being an ES module, it should be updated to use ESM syntax (export default, import).
| // config/config.default.js | |
| exports.tracer = { | |
| Class: require('path/to/my_tracer.js'), | |
| }; | |
| ``` | |
| // config/config.default.js | |
| import MyTracer from 'path/to/my_tracer.js'; | |
| export default { | |
| tracer: { | |
| Class: MyTracer, | |
| }, | |
| }; |
|
|
||
| module.exports = app => { | ||
| app.get('/', async function () { | ||
| assert.equal(this.traceId, this.traceId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Class: class Tracer { | ||
| constructor(ctx) { | ||
| this.ctx = ctx; | ||
| this.name = ctx.locals.name; | ||
| } | ||
|
|
||
| get traceId() { | ||
| if (!this.TRACE_ID) { | ||
| this.TRACE_ID = Date.now(); | ||
| } | ||
| return this.TRACE_ID; | ||
| } | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This custom Tracer class for testing has a couple of areas for improvement:
- The property
TRACE_IDis written in all-caps, which usually denotes a constant, but it's being mutated. This can be confusing. A name like_traceIdwould be more conventional for a private-like, mutable property. - The constructor accesses
ctx.locals.name. When this tracer is used forapp.traceroragent.tracer, it receives an anonymous context wherectx.localscan be undefined. Using optional chaining (?.) would make this access safer.
| Class: class Tracer { | |
| constructor(ctx) { | |
| this.ctx = ctx; | |
| this.name = ctx.locals.name; | |
| } | |
| get traceId() { | |
| if (!this.TRACE_ID) { | |
| this.TRACE_ID = Date.now(); | |
| } | |
| return this.TRACE_ID; | |
| } | |
| }, | |
| Class: class Tracer { | |
| constructor(ctx) { | |
| this.ctx = ctx; | |
| this.name = ctx.locals?.name; | |
| } | |
| get traceId() { | |
| if (!this._traceId) { | |
| this._traceId = Date.now(); | |
| } | |
| return this._traceId; | |
| } | |
| }, |
| module.exports = app => { | ||
| app.get('/', async ctx => { | ||
| assert(ctx.traceId); | ||
| assert.equal(ctx.traceId, ctx.traceId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🧹 Nitpick comments (1)
plugins/tracer/README.md (1)
64-64: Use descriptive link text for accessibility.markdownlint (MD059) flags “here” because screen readers lose context. Please switch to descriptive text like “open an issue on GitHub”.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (36)
CLAUDE.md(1 hunks)plugins/tracer/CHANGELOG.md(1 hunks)plugins/tracer/LICENSE(1 hunks)plugins/tracer/README.md(1 hunks)plugins/tracer/package.json(1 hunks)plugins/tracer/src/agent.ts(1 hunks)plugins/tracer/src/app.ts(1 hunks)plugins/tracer/src/app/extend/agent.ts(1 hunks)plugins/tracer/src/app/extend/application.ts(1 hunks)plugins/tracer/src/app/extend/context.ts(1 hunks)plugins/tracer/src/boot.ts(1 hunks)plugins/tracer/src/config/config.default.ts(1 hunks)plugins/tracer/src/index.ts(1 hunks)plugins/tracer/src/lib/tracer.ts(1 hunks)plugins/tracer/src/types.ts(1 hunks)plugins/tracer/src/typings/index.d.ts(1 hunks)plugins/tracer/test/error.tracer.test.ts(1 hunks)plugins/tracer/test/fixtures/apps/error-tracer-test/agent.js(1 hunks)plugins/tracer/test/fixtures/apps/error-tracer-test/app.js(1 hunks)plugins/tracer/test/fixtures/apps/error-tracer-test/app/router.js(1 hunks)plugins/tracer/test/fixtures/apps/error-tracer-test/config/config.default.js(1 hunks)plugins/tracer/test/fixtures/apps/error-tracer-test/package.json(1 hunks)plugins/tracer/test/fixtures/apps/plugin-test/agent.js(1 hunks)plugins/tracer/test/fixtures/apps/plugin-test/app.js(1 hunks)plugins/tracer/test/fixtures/apps/plugin-test/app/router.js(1 hunks)plugins/tracer/test/fixtures/apps/plugin-test/config/config.default.js(1 hunks)plugins/tracer/test/fixtures/apps/plugin-test/package.json(1 hunks)plugins/tracer/test/index.test-d.ts(1 hunks)plugins/tracer/test/index.test.ts(1 hunks)plugins/tracer/test/plugin.test.ts(1 hunks)plugins/tracer/test/tracer.test.ts(1 hunks)plugins/tracer/tsconfig.json(1 hunks)plugins/tracer/tsdown.config.ts(1 hunks)plugins/tracer/vitest.config.ts(1 hunks)tools/create-egg/src/templates/tegg/package.json(1 hunks)tsconfig.json(1 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
**/tsconfig.json
📄 CodeRabbit inference engine (CLAUDE.md)
**/tsconfig.json: All sub-project tsconfig.json files MUST extend from the root tsconfig.json using 'extends': '../../tsconfig.json'
Include 'baseUrl': './' in compilerOptions of tsconfig.json for proper path resolution
Files:
plugins/tracer/tsconfig.jsontsconfig.json
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: Prefer TypeScript and ESM: write sources and exports in .ts (ESM-first) rather than CommonJS
Use two-space indentation, trailing commas, and semicolons (Prettier/oxlint defaults)
Name files in lowercase with hyphens (e.g., loader-context.ts)
Name classes in PascalCase
Name functions and variables in camelCase
Re-export types thoughtfully to keep the public API stable
**/*.ts: Enable TypeScript strict mode in all packages
Use explicit return types for public APIs in TypeScript
Prefer interfaces over type aliases for object shapes in TypeScript
Use readonly modifiers where appropriate in TypeScript
Avoid the 'any' type; use 'unknown' when type is truly unknown in TypeScript
Files:
plugins/tracer/src/index.tsplugins/tracer/src/agent.tsplugins/tracer/src/app.tsplugins/tracer/src/app/extend/agent.tsplugins/tracer/src/typings/index.d.tsplugins/tracer/src/config/config.default.tsplugins/tracer/src/types.tsplugins/tracer/src/boot.tsplugins/tracer/test/index.test.tsplugins/tracer/src/app/extend/context.tsplugins/tracer/tsdown.config.tsplugins/tracer/test/index.test-d.tsplugins/tracer/test/tracer.test.tsplugins/tracer/vitest.config.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/src/lib/tracer.tsplugins/tracer/test/plugin.test.tsplugins/tracer/src/app/extend/application.ts
**/test/fixtures/**
📄 CodeRabbit inference engine (AGENTS.md)
Put reusable test data under test/fixtures/
Files:
plugins/tracer/test/fixtures/apps/plugin-test/package.jsonplugins/tracer/test/fixtures/apps/plugin-test/agent.jsplugins/tracer/test/fixtures/apps/error-tracer-test/app/router.jsplugins/tracer/test/fixtures/apps/plugin-test/app.jsplugins/tracer/test/fixtures/apps/plugin-test/config/config.default.jsplugins/tracer/test/fixtures/apps/error-tracer-test/package.jsonplugins/tracer/test/fixtures/apps/plugin-test/app/router.jsplugins/tracer/test/fixtures/apps/error-tracer-test/agent.jsplugins/tracer/test/fixtures/apps/error-tracer-test/app.jsplugins/tracer/test/fixtures/apps/error-tracer-test/config/config.default.js
**/package.json
📄 CodeRabbit inference engine (CLAUDE.md)
**/package.json: All plugins must include egg in peerDependencies in package.json
No ESLint configurations should be present and lint command should be 'oxlint --type-aware' in package.json scripts
Files:
plugins/tracer/test/fixtures/apps/plugin-test/package.jsonplugins/tracer/test/fixtures/apps/error-tracer-test/package.jsonplugins/tracer/package.jsontools/create-egg/src/templates/tegg/package.json
plugins/*/src/types.ts
📄 CodeRabbit inference engine (CLAUDE.md)
plugins/*/src/types.ts: All plugins MUST define a 'src/types.ts' file that uses module augmentation for the 'egg' module and extends appropriate interfaces
Plugin 'src/types.ts' files must import configuration types from './config/config.default.ts' using relative paths with .ts extensions
Plugin 'src/types.ts' files must use module augmentation to extend EggAppConfig and other interfaces (Application, Context, etc.)
Files:
plugins/tracer/src/types.ts
**/test/**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/test/**/*.test.ts: Place test suites following Vitest discovery: /test//*.test.ts
Mirror the repository test pattern when adding new suites
**/test/**/*.test.ts: All new package tests (except egg-bin and cookies) MUST use Vitest and import test functions from 'vitest'
Test files should be named *.test.ts and live under test/
Files:
plugins/tracer/test/index.test.tsplugins/tracer/test/tracer.test.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/plugin.test.ts
plugins/*/tsdown.config.ts
📄 CodeRabbit inference engine (CLAUDE.md)
All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)
Files:
plugins/tracer/tsdown.config.ts
{tsconfig.json,packages/*/tsconfig.json}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Enable strict TypeScript mode across all packages
Files:
tsconfig.json
tsconfig.json
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Root tsconfig.json must include all packages in the references array
Files:
tsconfig.json
plugins/*/package.json
📄 CodeRabbit inference engine (CLAUDE.md)
plugins/*/package.json: All plugins must configure their package.json with appropriate type/module/export fields, 'files' including 'dist', and scripts, as per the prescribed template. 'prepublishOnly' must run 'build'.
Published plugins should use 'publishConfig.exports' to mirror 'exports' with compiled output in dist for npm publishes
Files:
plugins/tracer/package.json
🧠 Learnings (24)
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to **/tsconfig.json : Include 'baseUrl': './' in compilerOptions of tsconfig.json for proper path resolution
Applied to files:
plugins/tracer/tsconfig.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/tsdown.config.ts : All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)
Applied to files:
plugins/tracer/tsconfig.jsonplugins/tracer/tsdown.config.tstsconfig.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to **/tsconfig.json : All sub-project tsconfig.json files MUST extend from the root tsconfig.json using 'extends': '../../tsconfig.json'
Applied to files:
plugins/tracer/tsconfig.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/types.ts : Plugin 'src/types.ts' files must import configuration types from './config/config.default.ts' using relative paths with .ts extensions
Applied to files:
plugins/tracer/tsconfig.jsonplugins/tracer/tsdown.config.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/*/tsconfig.json : All sub-project tsconfig.json files must extend from the root via "extends": "../../tsconfig.json"
Applied to files:
plugins/tracer/tsconfig.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to **/*.ts : Enable TypeScript strict mode in all packages
Applied to files:
plugins/tracer/tsconfig.json
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/*.ts : Re-export types thoughtfully to keep the public API stable
Applied to files:
plugins/tracer/src/index.tsplugins/tracer/src/app.tsplugins/tracer/src/typings/index.d.tsplugins/tracer/src/types.tsplugins/tracer/test/index.test-d.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/types.ts : All plugins MUST define a 'src/types.ts' file that uses module augmentation for the 'egg' module and extends appropriate interfaces
Applied to files:
plugins/tracer/src/typings/index.d.tsplugins/tracer/src/types.tsplugins/tracer/test/plugin.test.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/types.ts : Plugin 'src/types.ts' files must use module augmentation to extend EggAppConfig and other interfaces (Application, Context, etc.)
Applied to files:
plugins/tracer/src/typings/index.d.tsplugins/tracer/src/config/config.default.tsplugins/tracer/src/types.tsplugins/tracer/test/index.test-d.tsplugins/tracer/test/plugin.test.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin uses Mocha for its tests
Applied to files:
plugins/tracer/src/typings/index.d.tsplugins/tracer/test/index.test.tsplugins/tracer/test/index.test-d.tsplugins/tracer/test/tracer.test.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/plugin.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use Node.js built-in assert module for test assertions
Applied to files:
plugins/tracer/test/index.test.tsplugins/tracer/test/index.test-d.tsplugins/tracer/test/tracer.test.tsplugins/tracer/test/error.tracer.test.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to **/test/**/*.test.ts : All new package tests (except egg-bin and cookies) MUST use Vitest and import test functions from 'vitest'
Applied to files:
plugins/tracer/test/index.test.tsplugins/tracer/test/index.test-d.tsplugins/tracer/vitest.config.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/plugin.test.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/test/**/*.test.ts : All new plugin tests should use Vitest as the test runner
Applied to files:
plugins/tracer/test/index.test.tsplugins/tracer/vitest.config.tsplugins/tracer/test/plugin.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
Applied to files:
plugins/tracer/test/index.test.tsplugins/tracer/vitest.config.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/*/tsdown.config.ts : Each package must provide a tsdown.config.ts for unbundled ESM builds
Applied to files:
plugins/tracer/tsdown.config.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: For features affecting HTTP or process orchestration, add regression tests that exercise both the CommonJS and TypeScript example apps
Applied to files:
plugins/tracer/test/index.test-d.tsplugins/tracer/test/tracer.test.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/plugin.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Applied to files:
plugins/tracer/vitest.config.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
Applied to files:
plugins/tracer/vitest.config.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to **/test/**/*.test.ts : Test files should be named *.test.ts and live under test/
Applied to files:
plugins/tracer/vitest.config.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to tsconfig.json : Root tsconfig.json must include all packages in the references array
Applied to files:
tsconfig.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/package.json : All plugins must configure their package.json with appropriate type/module/export fields, 'files' including 'dist', and scripts, as per the prescribed template. 'prepublishOnly' must run 'build'.
Applied to files:
plugins/tracer/package.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/package.json : Published plugins should use 'publishConfig.exports' to mirror 'exports' with compiled output in dist for npm publishes
Applied to files:
plugins/tracer/package.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to **/package.json : All plugins must include egg in peerDependencies in package.json
Applied to files:
plugins/tracer/package.jsontools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to packages/cookies/test/**/*.test.ts : The cookies package uses Mocha for its tests
Applied to files:
plugins/tracer/test/plugin.test.ts
🧬 Code graph analysis (19)
plugins/tracer/src/agent.ts (1)
plugins/tracer/src/boot.ts (1)
TracerBoot(4-10)
plugins/tracer/src/app.ts (1)
plugins/tracer/src/boot.ts (1)
TracerBoot(4-10)
plugins/tracer/test/fixtures/apps/plugin-test/agent.js (1)
plugins/tracer/test/fixtures/apps/error-tracer-test/agent.js (2)
agentBeforeReadyTracers(2-2)agentAfterReadyTracers(3-3)
plugins/tracer/src/app/extend/agent.ts (1)
plugins/tracer/src/app/extend/application.ts (1)
TracerApplication(7-21)
plugins/tracer/src/config/config.default.ts (2)
plugins/tracer/src/lib/tracer.ts (1)
Tracer(4-18)packages/egg/src/lib/types.ts (1)
EggAppConfig(123-297)
plugins/tracer/src/types.ts (2)
packages/egg/src/lib/types.ts (1)
EggAppConfig(123-297)plugins/tracer/src/lib/tracer.ts (1)
Tracer(4-18)
plugins/tracer/src/boot.ts (2)
packages/core/src/egg.ts (1)
EggCore(95-543)plugins/tracer/src/app/extend/application.ts (1)
isReady(5-5)
plugins/tracer/test/index.test.ts (1)
plugins/tracer/src/lib/tracer.ts (1)
Tracer(4-18)
plugins/tracer/test/fixtures/apps/plugin-test/app.js (1)
plugins/tracer/test/fixtures/apps/error-tracer-test/app.js (2)
appBeforeReadyTracers(2-2)appAfterReadyTracers(3-3)
plugins/tracer/src/app/extend/context.ts (1)
plugins/tracer/src/lib/tracer.ts (1)
Tracer(4-18)
plugins/tracer/tsdown.config.ts (1)
packages/egg/src/lib/types.ts (1)
defineConfig(105-107)
plugins/tracer/test/index.test-d.ts (2)
plugins/tracer/src/index.ts (1)
Tracer(8-8)plugins/tracer/src/lib/tracer.ts (1)
Tracer(4-18)
plugins/tracer/test/tracer.test.ts (2)
packages/egg/test/utils.ts (2)
MockApplication(24-24)mm(23-23)plugins/tracer/src/app/extend/application.ts (1)
isReady(5-5)
plugins/tracer/src/lib/tracer.ts (1)
plugins/tracer/src/index.ts (1)
Tracer(8-8)
plugins/tracer/test/fixtures/apps/plugin-test/app/router.js (1)
plugins/tracer/test/fixtures/apps/error-tracer-test/app/router.js (1)
assert(1-1)
plugins/tracer/test/fixtures/apps/error-tracer-test/agent.js (1)
plugins/tracer/test/fixtures/apps/plugin-test/agent.js (2)
agentBeforeReadyTracers(2-2)agentAfterReadyTracers(3-3)
plugins/tracer/test/fixtures/apps/error-tracer-test/app.js (1)
plugins/tracer/test/fixtures/apps/plugin-test/app.js (2)
appBeforeReadyTracers(2-2)appAfterReadyTracers(3-3)
plugins/tracer/test/fixtures/apps/error-tracer-test/config/config.default.js (1)
plugins/tracer/src/lib/tracer.ts (1)
Tracer(4-18)
plugins/tracer/src/app/extend/application.ts (2)
packages/core/src/egg.ts (1)
EggCore(95-543)plugins/tracer/src/lib/tracer.ts (1)
Tracer(4-18)
🪛 markdownlint-cli2 (0.18.1)
plugins/tracer/CHANGELOG.md
14-14: Bare URL used
(MD034, no-bare-urls)
25-25: Bare URL used
(MD034, no-bare-urls)
27-27: Bare URL used
(MD034, no-bare-urls)
75-75: Heading style
Expected: atx; Actual: setext
(MD003, heading-style)
78-78: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
79-79: Unordered list indentation
Expected: 0; Actual: 2
(MD007, ul-indent)
81-81: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
82-82: Unordered list indentation
Expected: 0; Actual: 2
(MD007, ul-indent)
84-84: Heading style
Expected: atx; Actual: setext
(MD003, heading-style)
87-87: Unordered list indentation
Expected: 0; Actual: 2
(MD007, ul-indent)
plugins/tracer/README.md
64-64: Link text should be descriptive
(MD059, descriptive-link-text)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
- GitHub Check: Test (macos-latest, 24, tools)
- GitHub Check: Test (ubuntu-latest, 22, tools)
- GitHub Check: Test (ubuntu-latest, 24, packages)
- GitHub Check: Test (windows-latest, 22, tools)
- GitHub Check: Test (windows-latest, 24, plugins)
- GitHub Check: Test (macos-latest, 24, packages)
- GitHub Check: Test (ubuntu-latest, 24, plugins)
- GitHub Check: Test (windows-latest, 24, packages)
- GitHub Check: Test (ubuntu-latest, 22, packages)
- GitHub Check: Test (macos-latest, 22, plugins)
- GitHub Check: Test (windows-latest, 22, plugins)
- GitHub Check: Test egg-bin (ubuntu-latest, 22)
- GitHub Check: Test egg-bin (windows-latest, 22)
- GitHub Check: Test egg-bin (ubuntu-latest, 24)
- GitHub Check: Test egg-bin (macos-latest, 22)
- GitHub Check: Test egg-bin (windows-latest, 24)
- GitHub Check: Test egg-bin (macos-latest, 24)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Cloudflare Pages: egg-v3
🔇 Additional comments (9)
tsconfig.json (1)
76-78: Tracer project reference wired upAdding
./plugins/tracerto the root references keeps the TS build graph complete for the new plugin—nice catch. As per coding guidelines.plugins/tracer/tsconfig.json (1)
1-6: Local tsconfig inherits correctlyExtending the workspace config and setting
baseUrlensures the plugin stays aligned with repo-wide TypeScript settings. As per coding guidelines.plugins/tracer/LICENSE (1)
1-21: MIT license in placeIncluding the MIT terms here keeps the plugin’s licensing consistent with the rest of the monorepo.
tools/create-egg/src/templates/tegg/package.json (1)
33-33: Template now points at tracer betaGood to see the scaffold pulling the beta tag so new apps pick up the merged plugin automatically.
plugins/tracer/test/fixtures/apps/plugin-test/config/config.default.js (1)
1-1: Fixture keys initializedSetting
exports.keysavoids the usual test warnings and matches the pattern used elsewhere.plugins/tracer/src/boot.ts (1)
7-9: Ready flag set at the right lifecycle hook.Setting the flag in
didLoadensures the application extension allows tracer access only after the plugin finishes loading.plugins/tracer/src/lib/tracer.ts (1)
12-17: Trace ID memoization looks good.Lazy generation with
randomUUIDkeeps the identifier stable per tracer instance without extra work when the value isn’t needed.plugins/tracer/test/fixtures/apps/error-tracer-test/app.js (1)
8-24: Fixture captures both pre- and post-ready access paths.Recording tracer access attempts before and after readiness mirrors the lifecycle guard the plugin enforces, so the companion tests can assert the expected behavior directly.
plugins/tracer/src/types.ts (1)
4-21: Type augmentation matches the runtime surface.The module augmentation mirrors the
ApplicationandContextextensions, keeping consumer typings aligned with the plugin’s public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
🧹 Nitpick comments (1)
plugins/tracer/test/utils.ts (1)
3-5: Add explicit return type to the helper. Exported utilities should spell out their return types so the public surface stays stable under strict TypeScript settings.-export function getFixtures(name: string) { +export function getFixtures(name: string): string { return path.join(import.meta.dirname, 'fixtures', name); }As per coding guidelines
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (29)
examples/helloworld-typescript/app.ts(1 hunks)examples/helloworld-typescript/app/middleware/hello.ts(1 hunks)examples/helloworld-typescript/config/config.default.ts(1 hunks)examples/helloworld-typescript/package.json(1 hunks)examples/helloworld-typescript/test/hello.test.ts(1 hunks)examples/helloworld-typescript/test/setup.ts(1 hunks)examples/helloworld-typescript/tsconfig.json(1 hunks)examples/helloworld-typescript/tsdown.config.ts(1 hunks)examples/helloworld-typescript/vitest.config.ts(1 hunks)package.json(3 hunks)packages/egg/src/lib/types.ts(1 hunks)plugins/tracer/package.json(1 hunks)plugins/tracer/src/agent.ts(1 hunks)plugins/tracer/src/app.ts(1 hunks)plugins/tracer/src/app/extend/agent.ts(1 hunks)plugins/tracer/src/app/extend/application.ts(1 hunks)plugins/tracer/src/app/extend/context.ts(1 hunks)plugins/tracer/src/boot.ts(1 hunks)plugins/tracer/src/config/config.default.ts(1 hunks)plugins/tracer/src/index.ts(1 hunks)plugins/tracer/src/lib/tracer.ts(1 hunks)plugins/tracer/src/types.ts(1 hunks)plugins/tracer/test/error.tracer.test.ts(1 hunks)plugins/tracer/test/index.test.ts(1 hunks)plugins/tracer/test/plugin.test.ts(1 hunks)plugins/tracer/test/tracer.test.ts(1 hunks)plugins/tracer/test/utils.ts(1 hunks)pnpm-workspace.yaml(3 hunks)tools/create-egg/test/cli.test.ts(2 hunks)
✅ Files skipped from review due to trivial changes (2)
- examples/helloworld-typescript/tsconfig.json
- packages/egg/src/lib/types.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- plugins/tracer/src/config/config.default.ts
- plugins/tracer/src/app/extend/context.ts
- plugins/tracer/src/app.ts
- plugins/tracer/test/index.test.ts
- plugins/tracer/src/app/extend/agent.ts
- plugins/tracer/package.json
- plugins/tracer/src/index.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: Prefer TypeScript and ESM: write sources and exports in .ts (ESM-first) rather than CommonJS
Use two-space indentation, trailing commas, and semicolons (Prettier/oxlint defaults)
Name files in lowercase with hyphens (e.g., loader-context.ts)
Name classes in PascalCase
Name functions and variables in camelCase
Re-export types thoughtfully to keep the public API stable
**/*.ts: Enable TypeScript strict mode in all packages
Use explicit return types for public APIs in TypeScript
Prefer interfaces over type aliases for object shapes in TypeScript
Use readonly modifiers where appropriate in TypeScript
Avoid the 'any' type; use 'unknown' when type is truly unknown in TypeScript
Files:
tools/create-egg/test/cli.test.tsplugins/tracer/src/boot.tsexamples/helloworld-typescript/test/hello.test.tsplugins/tracer/src/lib/tracer.tsexamples/helloworld-typescript/config/config.default.tsplugins/tracer/src/agent.tsexamples/helloworld-typescript/app.tsplugins/tracer/test/utils.tsplugins/tracer/test/plugin.test.tsplugins/tracer/src/app/extend/application.tsplugins/tracer/src/types.tsexamples/helloworld-typescript/test/setup.tsexamples/helloworld-typescript/tsdown.config.tsexamples/helloworld-typescript/vitest.config.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.tsexamples/helloworld-typescript/app/middleware/hello.ts
**/test/**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/test/**/*.test.ts: Place test suites following Vitest discovery: /test//*.test.ts
Mirror the repository test pattern when adding new suites
**/test/**/*.test.ts: All new package tests (except egg-bin and cookies) MUST use Vitest and import test functions from 'vitest'
Test files should be named *.test.ts and live under test/
Files:
tools/create-egg/test/cli.test.tsexamples/helloworld-typescript/test/hello.test.tsplugins/tracer/test/plugin.test.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.ts
**/package.json
📄 CodeRabbit inference engine (CLAUDE.md)
**/package.json: All plugins must include egg in peerDependencies in package.json
No ESLint configurations should be present and lint command should be 'oxlint --type-aware' in package.json scripts
Files:
package.jsonexamples/helloworld-typescript/package.json
pnpm-workspace.yaml
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Define dependency versions via the catalog section in pnpm-workspace.yaml and reference them with "catalog:"
Files:
pnpm-workspace.yaml
plugins/*/src/types.ts
📄 CodeRabbit inference engine (CLAUDE.md)
plugins/*/src/types.ts: All plugins MUST define a 'src/types.ts' file that uses module augmentation for the 'egg' module and extends appropriate interfaces
Plugin 'src/types.ts' files must import configuration types from './config/config.default.ts' using relative paths with .ts extensions
Plugin 'src/types.ts' files must use module augmentation to extend EggAppConfig and other interfaces (Application, Context, etc.)
Files:
plugins/tracer/src/types.ts
🧠 Learnings (21)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/types.ts : Plugin 'src/types.ts' files must use module augmentation to extend EggAppConfig and other interfaces (Application, Context, etc.)
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin uses Mocha for its tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/types.ts : All plugins MUST define a 'src/types.ts' file that uses module augmentation for the 'egg' module and extends appropriate interfaces
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin uses Mocha for its tests
Applied to files:
tools/create-egg/test/cli.test.tsexamples/helloworld-typescript/test/hello.test.tsplugins/tracer/test/plugin.test.tsexamples/helloworld-typescript/test/setup.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.tsexamples/helloworld-typescript/package.json
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Run pnpm run test locally before submitting changes
Applied to files:
tools/create-egg/test/cli.test.tspackage.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/package.json : All plugins must configure their package.json with appropriate type/module/export fields, 'files' including 'dist', and scripts, as per the prescribed template. 'prepublishOnly' must run 'build'.
Applied to files:
package.jsonexamples/helloworld-typescript/package.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to **/test/**/*.test.ts : All new package tests (except egg-bin and cookies) MUST use Vitest and import test functions from 'vitest'
Applied to files:
examples/helloworld-typescript/test/hello.test.tsplugins/tracer/test/plugin.test.tsexamples/helloworld-typescript/test/setup.tsexamples/helloworld-typescript/vitest.config.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.tsexamples/helloworld-typescript/package.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/test/**/*.test.ts : All new plugin tests should use Vitest as the test runner
Applied to files:
examples/helloworld-typescript/test/hello.test.tsplugins/tracer/test/plugin.test.tsexamples/helloworld-typescript/test/setup.tsexamples/helloworld-typescript/vitest.config.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Applied to files:
examples/helloworld-typescript/test/hello.test.tsexamples/helloworld-typescript/test/setup.tsexamples/helloworld-typescript/vitest.config.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
Applied to files:
examples/helloworld-typescript/test/hello.test.tsplugins/tracer/test/plugin.test.tsexamples/helloworld-typescript/test/setup.tsexamples/helloworld-typescript/vitest.config.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: For features affecting HTTP or process orchestration, add regression tests that exercise both the CommonJS and TypeScript example apps
Applied to files:
examples/helloworld-typescript/test/hello.test.tsplugins/tracer/test/plugin.test.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
Applied to files:
examples/helloworld-typescript/test/hello.test.tsexamples/helloworld-typescript/test/setup.tsexamples/helloworld-typescript/vitest.config.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/types.ts : Plugin 'src/types.ts' files must use module augmentation to extend EggAppConfig and other interfaces (Application, Context, etc.)
Applied to files:
examples/helloworld-typescript/config/config.default.tsexamples/helloworld-typescript/app.tsplugins/tracer/test/plugin.test.tsplugins/tracer/src/types.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/*.ts : Re-export types thoughtfully to keep the public API stable
Applied to files:
examples/helloworld-typescript/config/config.default.tsplugins/tracer/src/types.tsexamples/helloworld-typescript/tsdown.config.tsexamples/helloworld-typescript/package.jsonexamples/helloworld-typescript/app/middleware/hello.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/types.ts : All plugins MUST define a 'src/types.ts' file that uses module augmentation for the 'egg' module and extends appropriate interfaces
Applied to files:
plugins/tracer/test/plugin.test.tsplugins/tracer/src/types.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to packages/cookies/test/**/*.test.ts : The cookies package uses Mocha for its tests
Applied to files:
plugins/tracer/test/plugin.test.tsplugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to pnpm-workspace.yaml : Define dependency versions via the catalog section in pnpm-workspace.yaml and reference them with "catalog:"
Applied to files:
pnpm-workspace.yamlexamples/helloworld-typescript/package.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to **/package.json : All plugins must include egg in peerDependencies in package.json
Applied to files:
pnpm-workspace.yamlexamples/helloworld-typescript/package.json
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/types.ts : Plugin 'src/types.ts' files must import configuration types from './config/config.default.ts' using relative paths with .ts extensions
Applied to files:
plugins/tracer/src/types.tsexamples/helloworld-typescript/tsdown.config.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/tsdown.config.ts : All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)
Applied to files:
examples/helloworld-typescript/tsdown.config.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/*/tsdown.config.ts : Each package must provide a tsdown.config.ts for unbundled ESM builds
Applied to files:
examples/helloworld-typescript/tsdown.config.tsexamples/helloworld-typescript/package.json
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use Node.js built-in assert module for test assertions
Applied to files:
plugins/tracer/test/error.tracer.test.tsplugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: All packages must include TypeScript type checking via 'tsc --noEmit' in the typecheck script
Applied to files:
examples/helloworld-typescript/package.json
🧬 Code graph analysis (10)
plugins/tracer/src/boot.ts (2)
packages/egg/src/lib/egg.ts (1)
EggApplicationCore(74-670)plugins/tracer/src/app/extend/application.ts (1)
isReady(6-6)
plugins/tracer/src/lib/tracer.ts (1)
plugins/tracer/src/index.ts (1)
Tracer(9-9)
examples/helloworld-typescript/config/config.default.ts (1)
packages/egg/src/lib/types.ts (1)
PartialEggConfig(86-86)
plugins/tracer/src/agent.ts (1)
plugins/tracer/src/boot.ts (1)
TracerBoot(5-14)
plugins/tracer/test/plugin.test.ts (1)
plugins/tracer/test/utils.ts (1)
getFixtures(3-5)
plugins/tracer/src/app/extend/application.ts (1)
plugins/tracer/src/lib/tracer.ts (1)
Tracer(5-19)
plugins/tracer/src/types.ts (3)
packages/egg/src/lib/types.ts (1)
EggAppConfig(123-298)plugins/tracer/src/config/config.default.ts (1)
TracerConfig(3-5)plugins/tracer/src/lib/tracer.ts (1)
Tracer(5-19)
examples/helloworld-typescript/tsdown.config.ts (1)
packages/egg/src/lib/types.ts (1)
defineConfig(105-107)
plugins/tracer/test/error.tracer.test.ts (2)
plugins/tracer/test/utils.ts (1)
getFixtures(3-5)packages/supertest/src/test.ts (1)
expect(77-132)
plugins/tracer/test/tracer.test.ts (2)
plugins/tracer/test/utils.ts (1)
getFixtures(3-5)plugins/tracer/src/app/extend/application.ts (1)
isReady(6-6)
🪛 GitHub Check: Test (ubuntu-latest, 24, plugins)
plugins/tracer/test/tracer.test.ts
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
🪛 GitHub Check: Test (ubuntu-latest, 22, plugins)
plugins/tracer/test/tracer.test.ts
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
- GitHub Check: Test (ubuntu-latest, 22, tools)
- GitHub Check: Test (windows-latest, 24, tools)
- GitHub Check: Test (windows-latest, 24, plugins)
- GitHub Check: Test (macos-latest, 22, plugins)
- GitHub Check: Test (macos-latest, 24, packages)
- GitHub Check: Test (windows-latest, 22, plugins)
- GitHub Check: Test (windows-latest, 24, packages)
- GitHub Check: Test (ubuntu-latest, 24, packages)
- GitHub Check: Test (macos-latest, 22, packages)
- GitHub Check: Test (ubuntu-latest, 22, packages)
- GitHub Check: Test (windows-latest, 22, packages)
- GitHub Check: Test egg-bin (ubuntu-latest, 24)
- GitHub Check: Test egg-bin (macos-latest, 22)
- GitHub Check: Test egg-bin (macos-latest, 24)
- GitHub Check: Test egg-bin (windows-latest, 22)
- GitHub Check: Test egg-bin (ubuntu-latest, 22)
- GitHub Check: Test egg-bin (windows-latest, 24)
🔇 Additional comments (5)
examples/helloworld-typescript/app/middleware/hello.ts (1)
1-1: Good call on using a type-only import.This keeps the runtime bundle lean while preserving the typing contract.
examples/helloworld-typescript/tsdown.config.ts (1)
1-10: Config matches tsdown template.Configuration aligns with the expected unbundled tsdown defaults and keeps dev exports enabled for tooling. Looks good.
plugins/tracer/test/plugin.test.ts (1)
6-24: Restore egg mocks between tests
mmholds global state; without resetting it each spec can leak mocks or fake timers into later suites. Please add anafterEachthat callsmm.restore().-import { describe, it, beforeAll, afterAll } from 'vitest'; +import { describe, it, beforeAll, afterAll, afterEach } from 'vitest'; @@ - afterAll(() => app.close()); + afterAll(() => app.close()); + + afterEach(() => { + mm.restore(); + });plugins/tracer/test/error.tracer.test.ts (1)
1-34: Restore mocks between specsAs with the other suites, we need to tear down
mmafter each case to keep the global mock registry clean.-import { describe, it, beforeAll, afterAll, expect } from 'vitest'; +import { describe, it, beforeAll, afterAll, afterEach, expect } from 'vitest'; @@ - afterAll(() => app.close()); + afterAll(() => app.close()); + + afterEach(() => { + mm.restore(); + });plugins/tracer/test/tracer.test.ts (1)
1-17: Reset mm after each caseThis suite also needs to clean up
mmto avoid leaking mocks into other runs.-import { describe, it, beforeAll, afterAll, expect } from 'vitest'; +import { describe, it, beforeAll, afterAll, afterEach, expect } from 'vitest'; @@ - afterAll(() => app.close()); + afterAll(() => app.close()); + + afterEach(() => { + mm.restore(); + });
|
|
||
| export default class AppBootHook implements ILifecycleBoot { | ||
| private readonly app: Application; | ||
| private readonly app; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore the explicit type on app field.
Dropping the Application annotation makes this property implicitly any, which breaks strict/noImplicitAny builds and erodes type safety. Please keep the explicit type.
Apply this diff:
- private readonly app;
+ private readonly app: Application;As per coding guidelines
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private readonly app; | |
| private readonly app: Application; |
🤖 Prompt for AI Agents
In examples/helloworld-typescript/app.ts around line 4, the private readonly app
field was left without an explicit type causing an implicit any; restore the
explicit Application type by declaring the field as private readonly app:
Application; and ensure the Application type is imported (e.g., from 'express'
or the correct framework) so the file compiles under strict/noImplicitAny.
| "@eggjs/bin": "workspace:*", | ||
| "@eggjs/mock": "workspace:*", | ||
| "@eggjs/tsconfig": "workspace:*", | ||
| "typescript": "catalog:" | ||
| "tsdown": "catalog:", | ||
| "typescript": "catalog:", | ||
| "vitest": "catalog:" | ||
| }, | ||
| "scripts": { | ||
| "dev": "egg-bin dev", | ||
| "debug": "egg-bin debug", | ||
| "test": "egg-bin test", | ||
| "cov": "egg-bin cov", | ||
| "test": "vitest run", | ||
| "cov": "vitest run --coverage", | ||
| "lint": "eslint . --ext .ts", | ||
| "ci": "pnpm run lint && pnpm run cov", | ||
| "prepublishOnly": "pnpm run build", | ||
| "start": "egg-scripts start --daemon", | ||
| "stop": "egg-scripts stop" | ||
| "stop": "egg-scripts stop", | ||
| "typecheck": "tsc --noEmit", | ||
| "build": "tsdown" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update example lint tooling to oxlint.
We switched the repo to oxlint, but this package’s scripts still invoke ESLint even though ESLint is no longer declared. The lint step (and anything calling pnpm run ci) will now fail because eslint isn’t installed. Please migrate the script and dev dependency to oxlint so the example stays consistent with the new toolchain.
Apply this diff to align with the workspace tooling:
"devDependencies": {
"@eggjs/bin": "workspace:*",
"@eggjs/mock": "workspace:*",
"@eggjs/tsconfig": "workspace:*",
+ "oxlint": "catalog:",
+ "oxlint-tsgolint": "catalog:",
"tsdown": "catalog:",
"typescript": "catalog:",
"vitest": "catalog:"
},
"scripts": {
"dev": "egg-bin dev",
"debug": "egg-bin debug",
- "test": "vitest run",
- "cov": "vitest run --coverage",
- "lint": "eslint . --ext .ts",
+ "test": "vitest run",
+ "cov": "vitest run --coverage",
+ "lint": "oxlint --type-aware",
"ci": "pnpm run lint && pnpm run cov",As per coding guidelines
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "@eggjs/bin": "workspace:*", | |
| "@eggjs/mock": "workspace:*", | |
| "@eggjs/tsconfig": "workspace:*", | |
| "typescript": "catalog:" | |
| "tsdown": "catalog:", | |
| "typescript": "catalog:", | |
| "vitest": "catalog:" | |
| }, | |
| "scripts": { | |
| "dev": "egg-bin dev", | |
| "debug": "egg-bin debug", | |
| "test": "egg-bin test", | |
| "cov": "egg-bin cov", | |
| "test": "vitest run", | |
| "cov": "vitest run --coverage", | |
| "lint": "eslint . --ext .ts", | |
| "ci": "pnpm run lint && pnpm run cov", | |
| "prepublishOnly": "pnpm run build", | |
| "start": "egg-scripts start --daemon", | |
| "stop": "egg-scripts stop" | |
| "stop": "egg-scripts stop", | |
| "typecheck": "tsc --noEmit", | |
| "build": "tsdown" | |
| }, | |
| "devDependencies": { | |
| "@eggjs/bin": "workspace:*", | |
| "@eggjs/mock": "workspace:*", | |
| "@eggjs/tsconfig": "workspace:*", | |
| "oxlint": "catalog:", | |
| "oxlint-tsgolint": "catalog:", | |
| "tsdown": "catalog:", | |
| "typescript": "catalog:", | |
| "vitest": "catalog:" | |
| }, | |
| "scripts": { | |
| "dev": "egg-bin dev", | |
| "debug": "egg-bin debug", | |
| "test": "vitest run", | |
| "cov": "vitest run --coverage", | |
| "lint": "oxlint --type-aware", | |
| "ci": "pnpm run lint && pnpm run cov", | |
| "prepublishOnly": "pnpm run build", | |
| "start": "egg-scripts start --daemon", | |
| "stop": "egg-scripts stop", | |
| "typecheck": "tsc --noEmit", | |
| "build": "tsdown" | |
| }, |
🤖 Prompt for AI Agents
In examples/helloworld-typescript/package.json around lines 16 to 35, the
package scripts still call eslint but the repo now uses oxlint; update the dev
dependency and scripts accordingly: replace any eslint devDependency with
oxlint, change the "lint" script from "eslint . --ext .ts" to the appropriate
oxlint invocation (e.g., "oxlint . --ext .ts" or the project-standard oxlint
CLI/flags), ensure "ci" still runs the lint and coverage steps (no other changes
needed), and remove any leftover references to eslint so pnpm install and pnpm
run ci succeed.
| import { beforeAll, afterAll } from 'vitest'; | ||
|
|
||
| // https://vitest.dev/config/#setupfiles | ||
| // export beforeAll and afterAll to globalThis, let @eggjs/mock/bootstrap use it | ||
| Object.assign(globalThis, { beforeAll, afterAll }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make Mocha-style globals available to @eggjs/mock/bootstrap
@eggjs/mock/bootstrap still registers hooks through Mocha names (before, after, afterEach). With Vitest’s default globals: false, those identifiers are undefined, so importing the bootstrap file throws ReferenceError: before is not defined and prevents the suite from ever starting. We need to surface the full hook set (and alias the Mocha names) on globalThis so the bootstrap module can wire itself up correctly.
-import { beforeAll, afterAll } from 'vitest';
+import { beforeAll, afterAll, beforeEach, afterEach } from 'vitest';
// https://vitest.dev/config/#setupfiles
// export beforeAll and afterAll to globalThis, let @eggjs/mock/bootstrap use it
-Object.assign(globalThis, { beforeAll, afterAll });
+Object.assign(globalThis, {
+ beforeAll,
+ afterAll,
+ beforeEach,
+ afterEach,
+ before: beforeAll,
+ after: afterAll,
+});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { beforeAll, afterAll } from 'vitest'; | |
| // https://vitest.dev/config/#setupfiles | |
| // export beforeAll and afterAll to globalThis, let @eggjs/mock/bootstrap use it | |
| Object.assign(globalThis, { beforeAll, afterAll }); | |
| import { beforeAll, afterAll, beforeEach, afterEach } from 'vitest'; | |
| // https://vitest.dev/config/#setupfiles | |
| // export Vitest hooks (and alias Mocha names) to globalThis so @eggjs/mock/bootstrap can register correctly | |
| Object.assign(globalThis, { | |
| beforeAll, | |
| afterAll, | |
| beforeEach, | |
| afterEach, | |
| // Mocha-style aliases | |
| before: beforeAll, | |
| after: afterAll, | |
| }); |
🤖 Prompt for AI Agents
In examples/helloworld-typescript/test/setup.ts around lines 1 to 5, Vitest
globals are only exposing beforeAll/afterAll but @eggjs/mock/bootstrap expects
Mocha names (before, after, beforeEach, afterEach); import beforeAll, afterAll,
beforeEach, afterEach from 'vitest' and assign all four Vitest functions to
globalThis while also aliasing the Mocha names (set globalThis.before =
beforeAll, globalThis.after = afterAll, globalThis.beforeEach = beforeEach,
globalThis.afterEach = afterEach) so the bootstrap file can use either API
without throwing ReferenceError.
| export default class TracerApplication extends Application { | ||
| [cacheTracer]: Tracer | undefined; | ||
|
|
||
| get tracer(): Tracer { | ||
| if (this[isReady]) { | ||
| return new this.config.tracer.Class(this.createAnonymousContext()); | ||
| } | ||
|
|
||
| if (!this[cacheTracer]) { | ||
| this[cacheTracer] = new this.config.tracer.Class(this.createAnonymousContext()); | ||
| } | ||
|
|
||
| return this[cacheTracer]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Export object-based extension instead of subclass
Egg loads app/extend/application.ts via loadExtend and Object.assign(Application.prototype, exports). Returning a subclass here means nothing is merged into the prototype, so app.tracer never gets defined and the plugin breaks. Please switch back to exporting a plain object extension.
-export default class TracerApplication extends Application {
- [cacheTracer]: Tracer | undefined;
-
- get tracer(): Tracer {
- if (this[isReady]) {
- return new this.config.tracer.Class(this.createAnonymousContext());
- }
-
- if (!this[cacheTracer]) {
- this[cacheTracer] = new this.config.tracer.Class(this.createAnonymousContext());
- }
-
- return this[cacheTracer];
- }
-}
+type TracerApplicationState = {
+ [cacheTracer]?: Tracer;
+ [isReady]?: boolean;
+};
+
+export default {
+ get tracer(this: Application & TracerApplicationState): Tracer {
+ if (this[isReady]) {
+ return new this.config.tracer.Class(this.createAnonymousContext());
+ }
+
+ if (!this[cacheTracer]) {
+ this[cacheTracer] = new this.config.tracer.Class(this.createAnonymousContext());
+ }
+
+ return this[cacheTracer];
+ },
+};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export default class TracerApplication extends Application { | |
| [cacheTracer]: Tracer | undefined; | |
| get tracer(): Tracer { | |
| if (this[isReady]) { | |
| return new this.config.tracer.Class(this.createAnonymousContext()); | |
| } | |
| if (!this[cacheTracer]) { | |
| this[cacheTracer] = new this.config.tracer.Class(this.createAnonymousContext()); | |
| } | |
| return this[cacheTracer]; | |
| } | |
| type TracerApplicationState = { | |
| [cacheTracer]?: Tracer; | |
| [isReady]?: boolean; | |
| }; | |
| export default { | |
| get tracer(this: Application & TracerApplicationState): Tracer { | |
| if (this[isReady]) { | |
| return new this.config.tracer.Class(this.createAnonymousContext()); | |
| } | |
| if (!this[cacheTracer]) { | |
| this[cacheTracer] = new this.config.tracer.Class(this.createAnonymousContext()); | |
| } | |
| return this[cacheTracer]; | |
| }, | |
| }; |
| private readonly app; | ||
| constructor(app: EggApplicationCore) { | ||
| this.app = app; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid implicit any on the app field
private readonly app; defaults to any under strict mode, violating the no-implicit-any policy we enforce for plugins. Please type it explicitly.
- private readonly app;
+ private readonly app: EggApplicationCore;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private readonly app; | |
| constructor(app: EggApplicationCore) { | |
| this.app = app; | |
| } | |
| private readonly app: EggApplicationCore; | |
| constructor(app: EggApplicationCore) { | |
| this.app = app; | |
| } |
🤖 Prompt for AI Agents
In plugins/tracer/src/boot.ts around lines 6 to 9, the class field is declared
as "private readonly app;" which is implicitly typed as any; explicitly type it
to match the constructor parameter (e.g., private readonly app:
EggApplicationCore) and ensure the EggApplicationCore type is imported or
referenced correctly so the file compiles under strict no-implicit-any rules.
| expect(app[isReady]).toBe(true); | ||
| expect(app.agent[isReady]).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app[isReady] never becomes true
CI is failing here (expected undefined to be true). That means the tracer boot logic is not flipping the isReady symbol on either the app or the agent. Please trace the lifecycle wiring (ensure TracerBoot is exported from both app.ts and agent.ts, and that didLoad actually runs) and set the flag before asserting on it.
🧰 Tools
🪛 GitHub Check: Test (ubuntu-latest, 24, plugins)
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
🪛 GitHub Check: Test (ubuntu-latest, 22, plugins)
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
[failure] 19-19: test/tracer.test.ts > test/tracer.test.ts > should get app, agent tracer
AssertionError: expected undefined to be true // Object.is equality
- Expected:
true
- Received:
undefined
❯ test/tracer.test.ts:19:26
🤖 Prompt for AI Agents
In plugins/tracer/test/tracer.test.ts around lines 19 to 20, the test fails
because app[isReady] and app.agent[isReady] are undefined — trace the lifecycle
wiring: confirm TracerBoot is exported/imported correctly from both app.ts and
agent.ts, verify the boot class is registered so didLoad/didReady run, and
ensure didLoad (or appropriate lifecycle method) sets the isReady symbol on both
app and agent before the test assertions; adjust exports/registration or call
the lifecycle hook in the test setup to guarantee the flag is set prior to
asserting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/koa-static-cache/test/index.test.ts (1)
261-275: Restore conditional skip instead of disabling the test entirelyThis suite used to run outside CI and caught regressions around the rollback
Last-Modifiedhandling. Changing it to a permanent skip drops that coverage for local runs as well. If the goal was to satisfy the stricter TS typing, we can keep the previous behavior by explicitly coercing the env flag:-it.skip('should set Last-Modified if file rollback and not buffered', async () => { +it.skipIf(Boolean(process.env.CI))('should set Last-Modified if file rollback and not buffered', async () => {
🧹 Nitpick comments (9)
plugins/tracer/test/tracer.test.ts (9)
1-6: Use a type‑only import and define a shared UUID regex once.Minor cleanup: import
MockApplicationas a type to avoid runtime import; also define a singleUUID_REto DRY the repeated regex and make it case‑insensitive.Apply:
-import { mm, MockApplication } from '@eggjs/mock'; +import { mm } from '@eggjs/mock'; +import type { MockApplication } from '@eggjs/mock'; @@ -import { isReady } from '../src/app/extend/application.ts'; +// See separate comment about centralizing isReady +import { isReady } from '../src/shared/symbols.ts'; import { getFixtures } from './utils.ts'; +const UUID_RE = + /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16-16: Await app.close in afterAll for deterministic cleanup.Returning a promise works, but an explicit async/await improves clarity.
-afterAll(() => app.close()); +afterAll(async () => { + await app.close(); +});
22-25: Guard destructuring with shape/length checks to avoid runtime errors.If these arrays are missing or shorter than expected, destructuring will throw. Assert existence and length first.
- let [appTracer_1, appTracer_2, appTracer_3] = app.appBeforeReadyTracers; - // @ts-expect-error agentBeforeReadyTracers is not exist on type Agent - let [agentTracer_1, agentTracer_2, agentTracer_3] = app.agent.agentBeforeReadyTracers; + expect(Array.isArray(app.appBeforeReadyTracers)).toBe(true); + expect(app.appBeforeReadyTracers).toHaveLength(3); + let [appTracer_1, appTracer_2, appTracer_3] = app.appBeforeReadyTracers; + // @ts-expect-error agentBeforeReadyTracers is not exist on type Agent + expect(Array.isArray(app.agent.agentBeforeReadyTracers)).toBe(true); + // @ts-expect-error agentBeforeReadyTracers is not exist on type Agent + expect(app.agent.agentBeforeReadyTracers).toHaveLength(3); + // @ts-expect-error agentBeforeReadyTracers is not exist on type Agent + let [agentTracer_1, agentTracer_2, agentTracer_3] = app.agent.agentBeforeReadyTracers;
29-31: DRY the UUID assertions and remove duplicates.Use the shared
UUID_REand drop repeatedtoMatchblocks that assert the same thing twice.- expect(appTracer_1.traceId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); - expect(appTracer_2.traceId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); - expect(appTracer_3.traceId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); + expect(appTracer_1.traceId).toMatch(UUID_RE); + expect(appTracer_2.traceId).toMatch(UUID_RE); + expect(appTracer_3.traceId).toMatch(UUID_RE); @@ - expect(agentTracer_1.traceId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); - expect(agentTracer_2.traceId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); - expect(agentTracer_3.traceId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); + expect(agentTracer_1.traceId).toMatch(UUID_RE); + expect(agentTracer_2.traceId).toMatch(UUID_RE); + expect(agentTracer_3.traceId).toMatch(UUID_RE); @@ - expect(agentTracer_1.traceId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); - expect(agentTracer_2.traceId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); - expect(agentTracer_3.traceId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); + // duplicate of lines 72-74; can be removedAlso applies to: 39-41, 46-48, 59-61, 72-74, 79-81
26-35: Remove duplicate equality assertions (beforeReady).These two lines are asserted twice; keep one set.
expect(appTracer_1).toBe(appTracer_2); expect(appTracer_1).toBe(appTracer_3); @@ - expect(appTracer_1).toBe(appTracer_2); - expect(appTracer_1).toBe(appTracer_3);
53-55: Add length checks before afterReady destructuring (app).Avoid potential destructuring errors.
- [appTracer_1, appTracer_2, appTracer_3] = app.appAfterReadyTracers; + expect(Array.isArray(app.appAfterReadyTracers)).toBe(true); + expect(app.appAfterReadyTracers).toHaveLength(3); + [appTracer_1, appTracer_2, appTracer_3] = app.appAfterReadyTracers;
56-68: Assert full pairwise inequality (app afterReady) and drop duplicates.Add the missing 2↔3 comparisons and remove duplicated pointer checks.
expect(appTracer_1).not.toBe(appTracer_2); expect(appTracer_1).not.toBe(appTracer_3); + expect(appTracer_2).not.toBe(appTracer_3); @@ - expect(appTracer_1).not.toBe(appTracer_2); - expect(appTracer_1).not.toBe(appTracer_3); expect(appTracer_1.traceId).not.toBe(appTracer_2.traceId); expect(appTracer_1.traceId).not.toBe(appTracer_3.traceId); + expect(appTracer_2.traceId).not.toBe(appTracer_3.traceId);
69-71: Add length checks before afterReady destructuring (agent).Same safeguard for the agent array.
- // @ts-expect-error agentAfterReadyTracers is not exist on type Agent - [agentTracer_1, agentTracer_2, agentTracer_3] = app.agent.agentAfterReadyTracers; + // @ts-expect-error agentAfterReadyTracers is not exist on type Agent + expect(Array.isArray(app.agent.agentAfterReadyTracers)).toBe(true); + // @ts-expect-error agentAfterReadyTracers is not exist on type Agent + expect(app.agent.agentAfterReadyTracers).toHaveLength(3); + // @ts-expect-error agentAfterReadyTracers is not exist on type Agent + [agentTracer_1, agentTracer_2, agentTracer_3] = app.agent.agentAfterReadyTracers;
76-84: Assert full pairwise inequality (agent afterReady).Add the missing 2↔3 comparisons for both instance and traceId uniqueness.
expect(agentTracer_1).not.toBe(agentTracer_2); expect(agentTracer_1).not.toBe(agentTracer_3); + expect(agentTracer_2).not.toBe(agentTracer_3); @@ expect(agentTracer_1.traceId).not.toBe(agentTracer_2.traceId); expect(agentTracer_1.traceId).not.toBe(agentTracer_3.traceId); + expect(agentTracer_2.traceId).not.toBe(agentTracer_3.traceId);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/koa-static-cache/test/index.test.ts(1 hunks)plugins/tracer/src/app/extend/application.ts(1 hunks)plugins/tracer/src/boot.ts(1 hunks)plugins/tracer/test/fixtures/apps/error-tracer-test/config/plugin.js(1 hunks)plugins/tracer/test/fixtures/apps/plugin-test/config/plugin.js(1 hunks)plugins/tracer/test/tracer.test.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- plugins/tracer/src/app/extend/application.ts
- plugins/tracer/src/boot.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/test/fixtures/**
📄 CodeRabbit inference engine (AGENTS.md)
Put reusable test data under test/fixtures/
Files:
plugins/tracer/test/fixtures/apps/plugin-test/config/plugin.jsplugins/tracer/test/fixtures/apps/error-tracer-test/config/plugin.js
packages/**/test/**/*.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
packages/**/test/**/*.test.ts: Name test files as test/**/*.test.ts and run them with Vitest
Use import { describe, it } from 'vitest' in tests
Use Node.js built-in assert module for test assertions
Files:
packages/koa-static-cache/test/index.test.ts
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: Prefer TypeScript and ESM: write sources and exports in .ts (ESM-first) rather than CommonJS
Use two-space indentation, trailing commas, and semicolons (Prettier/oxlint defaults)
Name files in lowercase with hyphens (e.g., loader-context.ts)
Name classes in PascalCase
Name functions and variables in camelCase
Re-export types thoughtfully to keep the public API stable
**/*.ts: Enable TypeScript strict mode in all packages
Use explicit return types for public APIs in TypeScript
Prefer interfaces over type aliases for object shapes in TypeScript
Use readonly modifiers where appropriate in TypeScript
Avoid the 'any' type; use 'unknown' when type is truly unknown in TypeScript
Files:
packages/koa-static-cache/test/index.test.tsplugins/tracer/test/tracer.test.ts
**/test/**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/test/**/*.test.ts: Place test suites following Vitest discovery: /test//*.test.ts
Mirror the repository test pattern when adding new suites
**/test/**/*.test.ts: All new package tests (except egg-bin and cookies) MUST use Vitest and import test functions from 'vitest'
Test files should be named *.test.ts and live under test/
Files:
packages/koa-static-cache/test/index.test.tsplugins/tracer/test/tracer.test.ts
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin uses Mocha for its tests
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: For features affecting HTTP or process orchestration, add regression tests that exercise both the CommonJS and TypeScript example apps
Applied to files:
plugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
Applied to files:
plugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to **/test/**/*.test.ts : All new package tests (except egg-bin and cookies) MUST use Vitest and import test functions from 'vitest'
Applied to files:
plugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to plugins/*/src/test/**/*.test.ts : All new plugin tests should use Vitest as the test runner
Applied to files:
plugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
Applied to files:
plugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Applied to files:
plugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use Node.js built-in assert module for test assertions
Applied to files:
plugins/tracer/test/tracer.test.ts
📚 Learning: 2025-09-28T05:47:59.051Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T05:47:59.051Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin uses Mocha for its tests
Applied to files:
plugins/tracer/test/tracer.test.ts
🧬 Code graph analysis (1)
plugins/tracer/test/tracer.test.ts (2)
plugins/tracer/test/utils.ts (1)
getFixtures(3-5)plugins/tracer/src/app/extend/application.ts (1)
isReady(10-10)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
- GitHub Check: Test (windows-latest, 22, tools)
- GitHub Check: Test (ubuntu-latest, 24, plugins)
- GitHub Check: Test (macos-latest, 22, packages)
- GitHub Check: Test (ubuntu-latest, 22, plugins)
- GitHub Check: Test (ubuntu-latest, 22, packages)
- GitHub Check: Test (ubuntu-latest, 24, packages)
- GitHub Check: Test (macos-latest, 24, packages)
- GitHub Check: Test (windows-latest, 24, plugins)
- GitHub Check: Test (windows-latest, 24, tools)
- GitHub Check: Test (windows-latest, 24, packages)
- GitHub Check: Test (windows-latest, 22, plugins)
- GitHub Check: Test (windows-latest, 22, packages)
- GitHub Check: Test egg-bin (ubuntu-latest, 24)
- GitHub Check: Test egg-bin (windows-latest, 24)
- GitHub Check: Test egg-bin (ubuntu-latest, 22)
- GitHub Check: Test egg-bin (windows-latest, 22)
- GitHub Check: Test egg-bin (macos-latest, 24)
- GitHub Check: Test egg-bin (macos-latest, 22)
- GitHub Check: typecheck
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Cloudflare Pages: egg-v3
🔇 Additional comments (1)
plugins/tracer/test/tracer.test.ts (1)
4-4: Unify and centralize the isReady symbol (fixes CI failure).Importing
isReadyfromapp/extend/application.tscouples the test to one module’s symbol instance. If the agent defines/uses a different symbol (even with the same description),app.agent[isReady]will beundefined. Extract the symbol to a single shared module and import it from both the app and agent code, then point the test at that shared export. PreferSymbol.for('eggjs/tracer/isReady')to guarantee a single global symbol.Apply in plugin code (outside this file):
+// plugins/tracer/src/shared/symbols.ts +export const isReady = Symbol.for('eggjs/tracer/isReady');-// plugins/tracer/src/app/extend/application.ts -export const isReady = Symbol('egg_tracer_is_ready'); +// plugins/tracer/src/app/extend/application.ts +export { isReady } from '../../shared/symbols';-// plugins/tracer/src/agent/extend/agent.ts -export const isReady = Symbol('egg_tracer_is_ready'); +// plugins/tracer/src/agent/extend/agent.ts +export { isReady } from '../../shared/symbols';And in this test:
-import { isReady } from '../src/app/extend/application.ts'; +import { isReady } from '../src/shared/symbols.ts';Run to verify there’s a single source of truth and that the flag is set:
#!/bin/bash # 1) Only one declaration site, and it uses Symbol.for rg -nP -C2 --type=ts 'export\s+const\s+isReady\s*=\s*Symbol' plugins/tracer/src || true rg -nP -C1 --type=ts 'Symbol\.for\([\'"]eggjs/tracer/isReady[\'"]\)' plugins/tracer/src || true # 2) All imports of isReady come from shared/symbols rg -nP -C1 --type=ts '\bisReady\b' plugins/tracer/src | rg -v 'shared/symbols' || true # 3) The readiness flag is flipped somewhere during boot rg -nP -C2 --type=ts '\[isReady\]\s*=\s*true' plugins/tracer/src || true # 4) Boot hooks exist and run rg -nP -C2 --type=ts '(didLoad|willReady|didReady)\s*\(' plugins/tracer/src || trueAs per coding guidelines

Merge @eggjs/tracer plugin from https://github.com/eggjs/tracer into monorepo at plugins/tracer/. Updated to version 4.0.0-beta.15 with standardized build configuration and dependencies.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests
Examples
Chores