Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prod-server): inject reporter from req #4919

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/unlucky-adults-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/prod-server': patch
---

fix(prod-server): inject reporter from req
fix(prod-server): 从 req 里拿到 reporter 去注入
3 changes: 3 additions & 0 deletions packages/server/prod-server/src/libs/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export class ModernServerContext implements ModernServerContextInterface {
this.res,
cutNameByHyphen(options?.metaName || 'modern-js'),
);

// inject reporter from req if it has.
req.reporter && (this.reporter = req.reporter);
}

private get parsedURL() {
Expand Down
2 changes: 2 additions & 0 deletions packages/server/prod-server/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import type {
NextFunction,
ModernServerContext,
InternalPlugins,
Reporter,
} from '@modern-js/types';
import type { ModernRouteInterface } from './libs/route';

declare module 'http' {
interface IncomingMessage {
logger: Logger;
metrics: Metrics;
reporter?: Reporter;
body?: any;
}

Expand Down