dowwntime 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -14888,14 +14888,16 @@ const measureRequest = async (url$2, options) => {
14888
14888
  const startAt = Date.now();
14889
14889
  return await new Promise((resolve$1) => {
14890
14890
  let tlsHandshakeAt;
14891
+ let firstByteAt;
14891
14892
  const req = ((typeof url$2 === "string" ? new URL(url$2) : url$2).protocol === "https:" ? https : http).request(url$2, options, (res) => {
14892
- res.on("data", () => {});
14893
+ res.on("data", () => {
14894
+ if (!firstByteAt) firstByteAt = Date.now();
14895
+ });
14893
14896
  res.on("end", () => {
14894
- const totalMs = Date.now() - startAt;
14895
- const tlsMs = tlsHandshakeAt ? tlsHandshakeAt - startAt : 0;
14897
+ const durationMs = (firstByteAt ? firstByteAt - startAt : 0) - (tlsHandshakeAt ? tlsHandshakeAt - startAt : 0);
14896
14898
  resolve$1({
14897
14899
  statusCode: res.statusCode || 0,
14898
- durationMs: totalMs - tlsMs
14900
+ durationMs: Math.max(0, durationMs)
14899
14901
  });
14900
14902
  });
14901
14903
  });