Skip to content

Commit c781ddf

Browse files
committed
lib: Fix http debug message crash
Commit cdcef6b improved debug messagse of `cockpit.http`. However, the `else` code path runs not only on success, but also if `resp` is false-y (i.e. the initial `null`), which can happen when the request fails before any response is received. Fix the crash on trying to read `null.status`.
1 parent ff7e48d commit c781ddf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/lib/cockpit.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2597,7 +2597,10 @@ function factory() {
25972597
http_debug("http", req.method, req.path, "failed:", resp.status, resp.reason);
25982598
dfd.reject(new HttpError(resp.status, resp.reason, message), body);
25992599
} else {
2600-
http_debug("http", req.method, req.path, "succeeded:", resp.status);
2600+
if (resp)
2601+
http_debug("http", req.method, req.path, "succeeded:", resp.status);
2602+
else
2603+
http_debug("http", req.method, req.path, "failed without response");
26012604
dfd.resolve(body);
26022605
}
26032606
}

0 commit comments

Comments
 (0)