dowwntime 1.3.1 → 1.3.3
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 +7 -5
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
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
|
|
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:
|
|
14900
|
+
durationMs: Math.max(0, durationMs)
|
|
14899
14901
|
});
|
|
14900
14902
|
});
|
|
14901
14903
|
});
|
|
@@ -28384,7 +28386,7 @@ const run = async (options) => {
|
|
|
28384
28386
|
let status = "down";
|
|
28385
28387
|
const statusCode = Math.max(...filteredResults.map((r) => r?.statusCode ?? 0));
|
|
28386
28388
|
if (options.getStatus) status = options.getStatus(statusCode, path$4, durationMs);
|
|
28387
|
-
else status = statusCode >= 200 ? "up" : "down";
|
|
28389
|
+
else status = statusCode >= 200 && statusCode < 300 ? "up" : "down";
|
|
28388
28390
|
const measurement = {
|
|
28389
28391
|
status,
|
|
28390
28392
|
durationMs,
|