[PR #5243] [CLOSED] fix: dashboard 'Clear Offline' fails with JSON parse error #5202

Closed
opened 2026-05-05 14:56:36 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/5243
Author: @mango766
Created: 3/17/2026
Status: Closed

Base: devHead: fix/clear-offline-proxies-empty-json-response


📝 Commits (1)

  • 3bc35e1 fix: dashboard 'Clear Offline' button fails with JSON parse error

📊 Changes

3 files changed (+17 additions, -4 deletions)

View changed files

📝 pkg/util/http/handler.go (+1 -1)
📝 server/http/controller.go (+1 -1)
📝 web/frps/src/api/http.ts (+15 -2)

📄 Description

Summary

Fixes the "Clear Offline" button on the frps dashboard crashing with:

Failed to execute 'json' on 'Response': Unexpected end of JSON input

This is a confirmed bug reported independently by multiple users (#5233, #5236).

Root Cause

Two issues work together to cause this:

  1. Backend (pkg/util/http/handler.go): MakeHTTPHandlerFunc returns HTTP 200 with an empty body when a handler returns nil. The frontend only skips JSON parsing for 204 responses, so an empty-body 200 causes response.json() to throw.

  2. Frontend (web/frps/src/api/http.ts): The request() function unconditionally calls response.json() on any non-204 response without checking Content-Type or body content. The frpc dashboard's http.ts already had this check — the frps version was missing it.

Changes

  • pkg/util/http/handler.go: Return 204 No Content (instead of 200 with empty body) when a handler returns nil. This is the correct REST semantics.
  • server/http/controller.go: DeleteProxies now returns nil (no body needed) — the 204 status code communicates success.
  • web/frps/src/api/http.ts: Added Content-Type check and empty-body handling before calling response.json(), consistent with the frpc dashboard implementation.

Test Plan

  • go test ./server/... — all tests pass
  • Go code compiles cleanly
  • Manual: open frps dashboard → Proxies → Clear Offline → should succeed without error

Fixes #5242
Related: #5233, #5236


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fatedier/frp/pull/5243 **Author:** [@mango766](https://github.com/mango766) **Created:** 3/17/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/clear-offline-proxies-empty-json-response` --- ### 📝 Commits (1) - [`3bc35e1`](https://github.com/fatedier/frp/commit/3bc35e1a29e22e9638f10efbd7cc05dbfdb65913) fix: dashboard 'Clear Offline' button fails with JSON parse error ### 📊 Changes **3 files changed** (+17 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `pkg/util/http/handler.go` (+1 -1) 📝 `server/http/controller.go` (+1 -1) 📝 `web/frps/src/api/http.ts` (+15 -2) </details> ### 📄 Description ## Summary Fixes the "Clear Offline" button on the frps dashboard crashing with: > Failed to execute 'json' on 'Response': Unexpected end of JSON input This is a confirmed bug reported independently by multiple users (#5233, #5236). ## Root Cause Two issues work together to cause this: 1. **Backend (`pkg/util/http/handler.go`)**: `MakeHTTPHandlerFunc` returns HTTP 200 with an **empty body** when a handler returns `nil`. The frontend only skips JSON parsing for 204 responses, so an empty-body 200 causes `response.json()` to throw. 2. **Frontend (`web/frps/src/api/http.ts`)**: The `request()` function unconditionally calls `response.json()` on any non-204 response without checking `Content-Type` or body content. The frpc dashboard's `http.ts` already had this check — the frps version was missing it. ## Changes - **`pkg/util/http/handler.go`**: Return `204 No Content` (instead of 200 with empty body) when a handler returns `nil`. This is the correct REST semantics. - **`server/http/controller.go`**: `DeleteProxies` now returns `nil` (no body needed) — the 204 status code communicates success. - **`web/frps/src/api/http.ts`**: Added `Content-Type` check and empty-body handling before calling `response.json()`, consistent with the frpc dashboard implementation. ## Test Plan - [x] `go test ./server/...` — all tests pass - [x] Go code compiles cleanly - [ ] Manual: open frps dashboard → Proxies → Clear Offline → should succeed without error Fixes #5242 Related: #5233, #5236 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 14:56:36 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#5202
No description provided.