[FIX] web: http_service: 502 errors should be handled as connection lost
Run Odoo behind nginx, load odoo, kill the server, and trigger the http service to make a request Before this commit it, the error code 502 was not handled After this commit, it is handled as if the server was unreachable altogether
This commit is contained in:
committed by
Aaron Bohy
parent
09e51c8809
commit
cc9d05e4ce
@@ -2,11 +2,18 @@
|
||||
|
||||
import { registry } from "../registry";
|
||||
|
||||
function checkResponseStatus(response) {
|
||||
if (response.status === 502) {
|
||||
throw new Error("Failed to fetch");
|
||||
}
|
||||
}
|
||||
|
||||
export const httpService = {
|
||||
start() {
|
||||
return {
|
||||
async get(route, readMethod = "json") {
|
||||
const response = await fetch(route, { method: "GET" });
|
||||
checkResponseStatus(response);
|
||||
return response[readMethod]();
|
||||
},
|
||||
async post(route, params = {}, readMethod = "json") {
|
||||
@@ -26,6 +33,7 @@ export const httpService = {
|
||||
method: "POST",
|
||||
};
|
||||
const response = await fetch(route, info);
|
||||
checkResponseStatus(response);
|
||||
return response[readMethod]();
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user