From 3d0dd0ca4b3dc0568661033feacc7649c8e0ed94 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 04:43:55 +0000 Subject: [PATCH 1/4] Initial plan From ed4655797a3eecfafc5f9dd2241d14d11a059fea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 04:53:34 +0000 Subject: [PATCH 2/4] Change proxy error status code from 500 to 502 Bad Gateway Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com> --- packages/vite/src/node/server/middlewares/proxy.ts | 2 +- playground/proxy-bypass/__tests__/proxy-bypass.spec.ts | 9 ++++++++- playground/proxy-bypass/vite.config.js | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/server/middlewares/proxy.ts b/packages/vite/src/node/server/middlewares/proxy.ts index 7c6d2b26fbd4b0..aade3270ff29fc 100644 --- a/packages/vite/src/node/server/middlewares/proxy.ts +++ b/packages/vite/src/node/server/middlewares/proxy.ts @@ -106,7 +106,7 @@ export function proxyMiddleware( ) if (!res.headersSent && !res.writableEnded) { res - .writeHead(500, { + .writeHead(502, { 'Content-Type': 'text/plain', }) .end() diff --git a/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts b/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts index b133f543f2e813..eb4e5c190f65c7 100644 --- a/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts +++ b/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts @@ -1,5 +1,5 @@ import { expect, test, vi } from 'vitest' -import { browserLogs, page, serverLogs } from '~utils' +import { browserLogs, isServe, page, serverLogs, viteTestUrl } from '~utils' test('proxy-bypass', async () => { await vi.waitFor(() => { @@ -17,3 +17,10 @@ test('async-proxy-bypass-with-error', async () => { expect(serverLogs.join('\n')).toContain('bypass error') }) }) + +test.runIf(isServe)('proxy error returns 502', async () => { + // proxyError tries to proxy to localhost:9608 which doesn't exist + // This should return 502 Bad Gateway instead of 500 Internal Server Error + const res = await fetch(viteTestUrl + '/proxyError') + expect(res.status).toBe(502) +}) diff --git a/playground/proxy-bypass/vite.config.js b/playground/proxy-bypass/vite.config.js index 1b40aebe5b2968..aa09f0d114d126 100644 --- a/playground/proxy-bypass/vite.config.js +++ b/playground/proxy-bypass/vite.config.js @@ -12,6 +12,9 @@ export default defineConfig({ return false }, }, + '/proxyError': { + target: 'http://localhost:9608', + }, '/asyncResponse': { bypass: async (_, res) => { await timeout(4) From 889abbb53e7e8f879d1a2714d637e8266f8e502f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 05:53:54 +0000 Subject: [PATCH 3/4] Use foo.invalid instead of localhost:9608 for proxy error test Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com> --- playground/proxy-bypass/__tests__/proxy-bypass.spec.ts | 2 +- playground/proxy-bypass/vite.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts b/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts index eb4e5c190f65c7..ab9378ff86e66f 100644 --- a/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts +++ b/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts @@ -19,7 +19,7 @@ test('async-proxy-bypass-with-error', async () => { }) test.runIf(isServe)('proxy error returns 502', async () => { - // proxyError tries to proxy to localhost:9608 which doesn't exist + // proxyError tries to proxy to foo.invalid which doesn't exist // This should return 502 Bad Gateway instead of 500 Internal Server Error const res = await fetch(viteTestUrl + '/proxyError') expect(res.status).toBe(502) diff --git a/playground/proxy-bypass/vite.config.js b/playground/proxy-bypass/vite.config.js index aa09f0d114d126..2b190df0ff8250 100644 --- a/playground/proxy-bypass/vite.config.js +++ b/playground/proxy-bypass/vite.config.js @@ -13,7 +13,7 @@ export default defineConfig({ }, }, '/proxyError': { - target: 'http://localhost:9608', + target: 'http://foo.invalid', }, '/asyncResponse': { bypass: async (_, res) => { From 174c59e5f85b8a4144b7b68d3ad339bfdadca0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0?= Date: Tue, 17 Feb 2026 15:26:50 +0900 Subject: [PATCH 4/4] chore: update --- playground/proxy-bypass/__tests__/proxy-bypass.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts b/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts index ab9378ff86e66f..c7b26adfdba0c4 100644 --- a/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts +++ b/playground/proxy-bypass/__tests__/proxy-bypass.spec.ts @@ -19,8 +19,6 @@ test('async-proxy-bypass-with-error', async () => { }) test.runIf(isServe)('proxy error returns 502', async () => { - // proxyError tries to proxy to foo.invalid which doesn't exist - // This should return 502 Bad Gateway instead of 500 Internal Server Error const res = await fetch(viteTestUrl + '/proxyError') expect(res.status).toBe(502) })