Skip to content

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Sep 28, 2025

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

Summary by CodeRabbit

  • New Features

    • Introduced a Tracer plugin for distributed request tracing with automatic trace IDs on app/context and response headers; supports pluggable custom tracers.
  • Documentation

    • Added plugin README and changelog; included license and usage guidance.
  • Tests

    • Added unit and integration tests and fixtures validating tracer behavior, lifecycle phases, and HTTP trace headers.
  • Examples

    • Updated TypeScript example with tracing, build/test configs, and tooling.
  • Chores

    • Updated workspace, package manifests, and build/tooling configs to include the new plugin.

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>
@fengmk2 fengmk2 requested a review from Copilot September 28, 2025 05:55
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 28, 2025

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

Adds 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

Cohort / File(s) Summary of Changes
Docs & License
CLAUDE.md, plugins/tracer/README.md, plugins/tracer/CHANGELOG.md, plugins/tracer/LICENSE
Added tracer documentation, changelog, and MIT license.
Plugin source & API
plugins/tracer/src/index.ts, plugins/tracer/src/lib/tracer.ts, plugins/tracer/src/boot.ts, plugins/tracer/src/agent.ts, plugins/tracer/src/app.ts, plugins/tracer/src/app/extend/application.ts, plugins/tracer/src/app/extend/agent.ts, plugins/tracer/src/app/extend/context.ts, plugins/tracer/src/config/config.default.ts, plugins/tracer/src/types.ts
New Tracer class (lazy UUID traceId), application/agent/context extensions, isReady symbol and TracerBoot lifecycle, default config exposing Class, and type augmentations; index re-exports Tracer.
Package & build config
plugins/tracer/package.json, plugins/tracer/tsconfig.json, plugins/tracer/tsdown.config.ts, plugins/tracer/vitest.config.ts
New package metadata with exports map, Node engine bounds, build/test scripts and configs (tsdown, Vitest), and TS project config.
Tests & fixtures
plugins/tracer/test/*.test.ts, plugins/tracer/test/utils.ts, plugins/tracer/test/fixtures/apps/*/**
Added unit and integration tests, test utilities, and two fixture apps (plugin-test, error-tracer-test) validating before/after readiness tracer behavior and HTTP header propagation.
Example app (TypeScript)
examples/helloworld-typescript/*
Switched to type-only imports, direct config object export, added build/test tooling, tsdown/vitest configs, tests, and package exports updates including @eggjs/tracer dependency.
Workspace & repo config
tsconfig.json, pnpm-workspace.yaml, package.json
Added project reference to plugins/tracer, added workspace catalog entry, adjusted root scripts (example test, clean), and linked tracer in workspace.
Scaffolding & tests
tools/create-egg/src/templates/tegg/package.json, tools/create-egg/test/cli.test.ts
Updated template dependency for @eggjs/tracer to "beta" and updated CLI tests to link the tracer plugin.
Minor test change
packages/koa-static-cache/test/index.test.ts
One test case changed from conditional skip to unconditional skip (it.skip).
JSDoc/type notes
packages/egg/src/lib/types.ts
JSDoc updated for EggAppConfig.keys (documentation only).

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
Loading
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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60–90 minutes

Poem

A rabbit pads the tracer's trail,
UUID seeds in every tail.
Before we're ready, hops repeat,
After ready, fresh and neat.
Headers glow — hop, trace complete. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately describes the primary change of merging the tracer plugin into the monorepo under plugins/tracer, matching the pull request objectives and focusing on the main feature addition.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tracer

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 @eggjs/tracer plugin directly into the Egg.js monorepo. This move aims to streamline the development process, standardize the plugin's build and testing infrastructure with modern tools like oxlint, tsdown, and Vitest, and ensure consistent dependency management. The update also includes enhanced TypeScript support and updated documentation, making the tracing capabilities a more integral part of the Egg.js ecosystem.

Highlights

  • Monorepo Integration: The @eggjs/tracer plugin has been merged into the main monorepo under plugins/tracer/, centralizing its development and maintenance.
  • Version Update: The tracer plugin is updated to version 4.0.0-beta.15, bringing the latest features and improvements.
  • Modernized Tooling: The build configuration and development dependencies have been standardized, including migrating from ESLint to oxlint for linting, using tsdown for unbundled builds, and updating tests to use Vitest.
  • Dependency Management: Dependencies have been converted to use workspace:* and catalog: for better monorepo integration and management.
  • TypeScript Support: Proper types.ts files have been added to enhance TypeScript support, and imports from @eggjs/core have been updated to egg.
  • Documentation Update: The main CLAUDE.md file has been updated to include a description of the new tracer/ plugin, detailing its capabilities for distributed tracing.
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 👍 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

  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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Sep 28, 2025

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: b4efe00
Status:🚫  Build failed.

View logs

Copy link
Contributor

Copilot AI left a 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

Comment on lines 17 to 22

declare module 'egg' {
interface EggAppConfig {
tracer: TracerConfig;
}
}
Copy link

Copilot AI Sep 28, 2025

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.

Suggested change
declare module 'egg' {
interface EggAppConfig {
tracer: TracerConfig;
}
}

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,22 @@
import type { TracerConfig } from './config/config.default.ts';
Copy link

Copilot AI Sep 28, 2025

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.

Suggested change
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
}

Copilot uses AI. Check for mistakes.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Sep 28, 2025

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: b4efe00
Status:🚫  Build failed.

View logs

@codecov
Copy link

codecov bot commented Sep 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.29%. Comparing base (3d7d57c) to head (b4efe00).
⚠️ Report is 1 commits behind head on next.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +40 to +51
// 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;
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The example for creating a custom tracer has a couple of issues that could mislead users:

  1. It uses CommonJS (require, module.exports). Since this package is an ES module ("type": "module"), the example should use ESM syntax (import/export).
  2. The counter variable is declared at the module level. This means all instances of MyTracer will share the same counter, which can lead to non-unique traceIds in a concurrent environment. It would be safer to make counter a static property of the class.
Suggested change
// 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;

Comment on lines +56 to +60
// config/config.default.js
exports.tracer = {
Class: require('path/to/my_tracer.js'),
};
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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).

Suggested change
// 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion assert.equal(this.traceId, this.traceId) is tautological and doesn't test anything meaningful. A better test would be to ensure the traceId is an alias for this.tracer.traceId.

Suggested change
assert.equal(this.traceId, this.traceId);
assert.equal(this.traceId, this.tracer.traceId);

Comment on lines +9 to +21
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;
}
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This custom Tracer class for testing has a couple of areas for improvement:

  1. The property TRACE_ID is written in all-caps, which usually denotes a constant, but it's being mutated. This can be confusing. A name like _traceId would be more conventional for a private-like, mutable property.
  2. The constructor accesses ctx.locals.name. When this tracer is used for app.tracer or agent.tracer, it receives an anonymous context where ctx.locals can be undefined. Using optional chaining (?.) would make this access safer.
Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion assert.equal(ctx.traceId, ctx.traceId) is tautological and doesn't test anything meaningful. A better test would be to ensure the traceId is an alias for ctx.tracer.traceId.

Suggested change
assert.equal(ctx.traceId, ctx.traceId);
assert.equal(ctx.traceId, ctx.tracer.traceId);

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3d7d57c and 2eaca9d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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.json
  • tsconfig.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.ts
  • plugins/tracer/src/agent.ts
  • plugins/tracer/src/app.ts
  • plugins/tracer/src/app/extend/agent.ts
  • plugins/tracer/src/typings/index.d.ts
  • plugins/tracer/src/config/config.default.ts
  • plugins/tracer/src/types.ts
  • plugins/tracer/src/boot.ts
  • plugins/tracer/test/index.test.ts
  • plugins/tracer/src/app/extend/context.ts
  • plugins/tracer/tsdown.config.ts
  • plugins/tracer/test/index.test-d.ts
  • plugins/tracer/test/tracer.test.ts
  • plugins/tracer/vitest.config.ts
  • plugins/tracer/test/error.tracer.test.ts
  • plugins/tracer/src/lib/tracer.ts
  • plugins/tracer/test/plugin.test.ts
  • plugins/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.json
  • plugins/tracer/test/fixtures/apps/plugin-test/agent.js
  • plugins/tracer/test/fixtures/apps/error-tracer-test/app/router.js
  • plugins/tracer/test/fixtures/apps/plugin-test/app.js
  • plugins/tracer/test/fixtures/apps/plugin-test/config/config.default.js
  • plugins/tracer/test/fixtures/apps/error-tracer-test/package.json
  • plugins/tracer/test/fixtures/apps/plugin-test/app/router.js
  • plugins/tracer/test/fixtures/apps/error-tracer-test/agent.js
  • plugins/tracer/test/fixtures/apps/error-tracer-test/app.js
  • plugins/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.json
  • plugins/tracer/test/fixtures/apps/error-tracer-test/package.json
  • plugins/tracer/package.json
  • tools/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.ts
  • plugins/tracer/test/tracer.test.ts
  • plugins/tracer/test/error.tracer.test.ts
  • plugins/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.json
  • plugins/tracer/tsdown.config.ts
  • 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 **/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.json
  • plugins/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.ts
  • plugins/tracer/src/app.ts
  • plugins/tracer/src/typings/index.d.ts
  • plugins/tracer/src/types.ts
  • plugins/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.ts
  • plugins/tracer/src/types.ts
  • plugins/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.ts
  • plugins/tracer/src/config/config.default.ts
  • plugins/tracer/src/types.ts
  • plugins/tracer/test/index.test-d.ts
  • plugins/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.ts
  • plugins/tracer/test/index.test.ts
  • plugins/tracer/test/index.test-d.ts
  • plugins/tracer/test/tracer.test.ts
  • plugins/tracer/test/error.tracer.test.ts
  • plugins/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.ts
  • plugins/tracer/test/index.test-d.ts
  • plugins/tracer/test/tracer.test.ts
  • plugins/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.ts
  • plugins/tracer/test/index.test-d.ts
  • plugins/tracer/vitest.config.ts
  • plugins/tracer/test/error.tracer.test.ts
  • plugins/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.ts
  • plugins/tracer/vitest.config.ts
  • plugins/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.ts
  • 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 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.ts
  • plugins/tracer/test/tracer.test.ts
  • plugins/tracer/test/error.tracer.test.ts
  • plugins/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.json
  • tools/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 up

Adding ./plugins/tracer to 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 correctly

Extending the workspace config and setting baseUrl ensures the plugin stays aligned with repo-wide TypeScript settings. As per coding guidelines.

plugins/tracer/LICENSE (1)

1-21: MIT license in place

Including 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 beta

Good 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 initialized

Setting exports.keys avoids 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 didLoad ensures 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 randomUUID keeps 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 Application and Context extensions, keeping consumer typings aligned with the plugin’s public API.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2eaca9d and 89c43ac.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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.ts
  • plugins/tracer/src/boot.ts
  • examples/helloworld-typescript/test/hello.test.ts
  • plugins/tracer/src/lib/tracer.ts
  • examples/helloworld-typescript/config/config.default.ts
  • plugins/tracer/src/agent.ts
  • examples/helloworld-typescript/app.ts
  • plugins/tracer/test/utils.ts
  • plugins/tracer/test/plugin.test.ts
  • plugins/tracer/src/app/extend/application.ts
  • plugins/tracer/src/types.ts
  • examples/helloworld-typescript/test/setup.ts
  • examples/helloworld-typescript/tsdown.config.ts
  • examples/helloworld-typescript/vitest.config.ts
  • plugins/tracer/test/error.tracer.test.ts
  • plugins/tracer/test/tracer.test.ts
  • examples/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.ts
  • examples/helloworld-typescript/test/hello.test.ts
  • plugins/tracer/test/plugin.test.ts
  • plugins/tracer/test/error.tracer.test.ts
  • plugins/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.json
  • examples/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.ts
  • examples/helloworld-typescript/test/hello.test.ts
  • plugins/tracer/test/plugin.test.ts
  • examples/helloworld-typescript/test/setup.ts
  • plugins/tracer/test/error.tracer.test.ts
  • plugins/tracer/test/tracer.test.ts
  • examples/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.ts
  • 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 : 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.json
  • examples/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.ts
  • plugins/tracer/test/plugin.test.ts
  • examples/helloworld-typescript/test/setup.ts
  • examples/helloworld-typescript/vitest.config.ts
  • plugins/tracer/test/error.tracer.test.ts
  • plugins/tracer/test/tracer.test.ts
  • examples/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.ts
  • plugins/tracer/test/plugin.test.ts
  • examples/helloworld-typescript/test/setup.ts
  • examples/helloworld-typescript/vitest.config.ts
  • plugins/tracer/test/error.tracer.test.ts
  • 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:

  • examples/helloworld-typescript/test/hello.test.ts
  • examples/helloworld-typescript/test/setup.ts
  • examples/helloworld-typescript/vitest.config.ts
  • plugins/tracer/test/error.tracer.test.ts
  • 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:

  • examples/helloworld-typescript/test/hello.test.ts
  • plugins/tracer/test/plugin.test.ts
  • examples/helloworld-typescript/test/setup.ts
  • examples/helloworld-typescript/vitest.config.ts
  • plugins/tracer/test/error.tracer.test.ts
  • 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: 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.ts
  • plugins/tracer/test/plugin.test.ts
  • plugins/tracer/test/error.tracer.test.ts
  • 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:

  • examples/helloworld-typescript/test/hello.test.ts
  • examples/helloworld-typescript/test/setup.ts
  • examples/helloworld-typescript/vitest.config.ts
  • plugins/tracer/test/error.tracer.test.ts
  • 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/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.ts
  • examples/helloworld-typescript/app.ts
  • plugins/tracer/test/plugin.test.ts
  • plugins/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.ts
  • plugins/tracer/src/types.ts
  • examples/helloworld-typescript/tsdown.config.ts
  • examples/helloworld-typescript/package.json
  • examples/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.ts
  • plugins/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.ts
  • plugins/tracer/test/error.tracer.test.ts
  • 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 pnpm-workspace.yaml : Define dependency versions via the catalog section in pnpm-workspace.yaml and reference them with "catalog:"

Applied to files:

  • pnpm-workspace.yaml
  • examples/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.yaml
  • examples/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.ts
  • examples/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.ts
  • examples/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.ts
  • 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: 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

mm holds global state; without resetting it each spec can leak mocks or fake timers into later suites. Please add an afterEach that calls mm.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 specs

As with the other suites, we need to tear down mm after 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 case

This suite also needs to clean up mm to 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.

Suggested change
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.

Comment on lines 16 to 35
"@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"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
"@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.

Comment on lines +1 to +5
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 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.

Suggested change
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.

Comment on lines 8 to 21
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];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.

Suggested change
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];
},
};

Comment on lines +6 to +9
private readonly app;
constructor(app: EggApplicationCore) {
this.app = app;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
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.

Comment on lines +19 to +20
expect(app[isReady]).toBe(true);
expect(app.agent[isReady]).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.

@fengmk2 fengmk2 merged commit 2c6f497 into next Sep 28, 2025
35 of 38 checks passed
@fengmk2 fengmk2 deleted the tracer branch September 28, 2025 06:52
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 entirely

This suite used to run outside CI and caught regressions around the rollback Last-Modified handling. 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 MockApplication as a type to avoid runtime import; also define a single UUID_RE to 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_RE and drop repeated toMatch blocks 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 removed

Also 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

📥 Commits

Reviewing files that changed from the base of the PR and between 89c43ac and b4efe00.

📒 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.js
  • plugins/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.ts
  • plugins/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.ts
  • plugins/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 isReady from app/extend/application.ts couples 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 be undefined. 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. Prefer Symbol.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 || true

As per coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant