Skip to content

Commit 6599c76

Browse files
fix(api): return 499 on copilot mcp user aborts
1 parent 154b9d0 commit 6599c76

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

apps/sim/app/api/mcp/copilot/route.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,13 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
567567

568568
return await handleMcpRequestWithSdk(request, parsedBody)
569569
} catch (error) {
570+
if (request.signal.aborted || (error as Error)?.name === 'AbortError') {
571+
return NextResponse.json(
572+
createError(0, ErrorCode.ConnectionClosed, 'Client cancelled request'),
573+
{ status: 499 }
574+
)
575+
}
576+
570577
logger.error('Error handling MCP request', { error })
571578
return NextResponse.json(createError(0, ErrorCode.InternalError, 'Internal error'), {
572579
status: 500,

0 commit comments

Comments
 (0)