Frontend service: Update boot failure request to GET (#112603)

* update boot failure request to GET, add notes about why/how

* remove now unused function

* remove unneeded header
This commit is contained in:
Luminessa Starlight
2025-10-20 11:46:37 -04:00
committed by GitHub
parent b1b7d81e0b
commit 0204bdab55
2 changed files with 10 additions and 15 deletions
+3 -6
View File
@@ -127,11 +127,6 @@ func (s *frontendService) routeGet(m *web.Mux, pattern string, h ...web.Handler)
m.Get(pattern, handlers...)
}
func (s *frontendService) routePost(m *web.Mux, pattern string, h ...web.Handler) {
handlers := append([]web.Handler{middleware.ProvideRouteOperationName(pattern)}, h...)
m.Post(pattern, handlers...)
}
// Apply the same middleware patterns as the main HTTP server
func (s *frontendService) addMiddlewares(m *web.Mux) {
loggermiddleware := loggermw.Provide(s.cfg, s.features)
@@ -164,7 +159,9 @@ func (s *frontendService) registerRoutes(m *web.Mux) {
})
// Frontend boot error reporting endpoint
s.routePost(m, "/-/fe-boot-error", s.handleBootError)
// GET because all POST requests are passed to the backend, even though POST is more correct. The frontend
// uses cache busting to ensure requests aren't cached.
s.routeGet(m, "/-/fe-boot-error", s.handleBootError)
// All other requests return index.html
s.routeGet(m, "/*", s.index.HandleRequest)
+7 -9
View File
@@ -174,15 +174,13 @@
document.querySelector('.fs-variant-loader').classList.add('fs-hidden');
document.querySelector('.fs-variant-error').classList.remove('fs-hidden');
// Report the error to the backend
const errorMessage = err ? err.message : 'Unknown error';
fetch('/-/fe-boot-error', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: errorMessage,
// not a secure random value, but collisions are highly unlikely and 1/1000_000_000 lost requests
// doesn't make a difference.
fetch(`/-/fe-boot-error?ts=${Date.now()}${Math.random()}`, {
// This "should" be a POST request, but we must use GET to interact with the correct service.
// no-store and ?ts=_ are used to ensure the request isn't cached.
method: 'GET',
cache: "no-store",
}).catch(err => {
console.error('Failed to report boot error to backend: ', err);
});