chore: debug playwright shutdown errors (#15456)
This commit is contained in:
parent
f73072d8c4
commit
f2267082d9
2 changed files with 11 additions and 4 deletions
|
|
@ -2,6 +2,7 @@ package server
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -97,6 +98,7 @@ func loginHandler(auth auth.Auth) http.HandlerFunc {
|
|||
}
|
||||
|
||||
if !auth.IsAdminPasswordValid(req.Password) {
|
||||
fmt.Println("auth: invalid password", req.Password)
|
||||
http.Error(w, "Invalid password", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
|
@ -133,6 +135,7 @@ func ensureAuthHandler(auth auth.Auth) mux.MiddlewareFunc {
|
|||
// check jwt token
|
||||
ok, err := auth.ValidateJwtToken(jwtFromRequest(r))
|
||||
if !ok || err != nil {
|
||||
fmt.Println("auth: invalid auth token", jwtFromRequest(r))
|
||||
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,10 +88,14 @@ async function _stop(instance) {
|
|||
}
|
||||
const port = workerPort();
|
||||
console.log("shutting down evcc", { port });
|
||||
const res = await axios.post(`${baseUrl()}/api/auth/login`, { password: "secret" });
|
||||
console.log(res.status, res.statusText);
|
||||
const cookie = res.headers["set-cookie"];
|
||||
await axios.post(`${baseUrl()}/api/system/shutdown`, {}, { headers: { cookie } });
|
||||
try {
|
||||
const res = await axios.post(`${baseUrl()}/api/auth/login`, { password: "secret" });
|
||||
console.log(res.status, res.statusText);
|
||||
const cookie = res.headers["set-cookie"];
|
||||
await axios.post(`${baseUrl()}/api/system/shutdown`, {}, { headers: { cookie } });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
console.log(`wait until port ${port} is closed`);
|
||||
await waitOn({ resources: [`tcp:localhost:${port}`], reverse: true });
|
||||
console.log("evcc is down", { port });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue