Skip to content

Commit 810c72e

Browse files
refactor: extract _handleInitialized method for clearer lifecycle hook
Mirrors the Go SDK pattern where the initialized notification handler is a named method rather than an inline closure.
1 parent 9e1b5da commit 810c72e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/server/src/server/server.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,18 @@ export class Server extends Protocol<ServerContext> {
133133
}
134134

135135
this.setRequestHandler('initialize', request => this._oninitialize(request));
136-
this.setNotificationHandler('notifications/initialized', () => {
137-
this.startPeriodicPing();
138-
this.oninitialized?.();
139-
});
136+
this.setNotificationHandler('notifications/initialized', () => this._handleInitialized());
140137

141138
if (this._capabilities.logging) {
142139
this._registerLoggingHandler();
143140
}
144141
}
145142

143+
private _handleInitialized(): void {
144+
this.startPeriodicPing();
145+
this.oninitialized?.();
146+
}
147+
146148
private _registerLoggingHandler(): void {
147149
this.setRequestHandler('logging/setLevel', async (request, ctx) => {
148150
const transportSessionId: string | undefined =

0 commit comments

Comments
 (0)