Skip to content

Commit f0fbfc7

Browse files
authored
StreamableHTTPServerTransport should only check init status when there is an sessionId
When using stateless mode, the backend will create a new transport for each request. For new transport, the initialized filed is always false. So we should only check the initialized filed if there is session existing
1 parent 56b0427 commit f0fbfc7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/server/streamableHttp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ export class StreamableHTTPServerTransport implements Transport {
371371
* Returns true if the session is valid, false otherwise
372372
*/
373373
private validateSession(req: IncomingMessage, res: ServerResponse): boolean {
374-
if (!this._initialized) {
374+
if (this.sessionId && !this._initialized) {
375375
// If the server has not been initialized yet, reject all requests
376376
res.writeHead(400).end(JSON.stringify({
377377
jsonrpc: "2.0",

0 commit comments

Comments
 (0)