-
Notifications
You must be signed in to change notification settings - Fork 356
fix: [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent … #295
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
Conversation
Hi @ycjcl868! How does adding an error handler fix the problem? I believe this has been fixed and will be out in the next version of the Inspector. Can you duplicate it with what is on I was getting it when troubleshooting #273 (comment) and that has been fixed with #290. Haven't seen it since. |
Based on the implementation of res.writeHead(500).end(message);
throw new Error(message); According to the handling logic in console.error("Error in /message route:", error);
res.status(500).json(error); This causes the server service to crash directly. |
@ycjcl868 Can you post exact steps to reproduce, along with which server you are running? |
@ycjcl868 Could you provide a video or set of screenshots showing how this behaves with and without your fix? Using |
Closing this for lack of testability / reproducibility. Feel free to reopen with details. |
…to the client
https://github.com/modelcontextprotocol/typescript-sdk/blob/c6668c1f807745a8ae7434702fcbad100c332d92/src/server/sse.ts#L86
Based on the implementation of
handlePostMessage
, it executes when there is no established SSE connection.According to the handling logic in
server/src/index.ts
, it is executed in the catch block:This causes the server service to crash directly.
Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context