Skip to content

Commit 4ea4610

Browse files
Vadaskiclaude
andcommitted
refactor: simplify stateless check back to sessionIdGenerator === undefined
Now that the constructor always sets sessionIdGenerator when existingSessionId is provided, the extra `&& sessionId === undefined` guard in validateSession is redundant. Revert to the clean single-condition check as suggested by reviewer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e3ec989 commit 4ea4610

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

packages/server/src/server/streamableHttp.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,11 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
861861
* Returns `Response` error if invalid, `undefined` otherwise
862862
*/
863863
private validateSession(req: Request): Response | undefined {
864-
if (this.sessionIdGenerator === undefined && this.sessionId === undefined) {
865-
// If sessionIdGenerator is not set and no session has been hydrated,
866-
// session management is disabled (stateless mode)
867-
// and we don't need to validate the session ID
864+
if (this.sessionIdGenerator === undefined) {
865+
// If sessionIdGenerator is not set, session management is disabled (stateless mode)
866+
// and we don't need to validate the session ID.
867+
// Note: when existingSessionId is provided, sessionIdGenerator is always set in the
868+
// constructor, so this check correctly identifies stateless mode.
868869
return undefined;
869870
}
870871
if (!this._initialized) {

0 commit comments

Comments
 (0)