metergraph-cli 0.2.0-preview.2 → 0.2.0-preview.4

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/src/verify.js CHANGED
@@ -28,15 +28,19 @@ export async function runVerify(options, dependencies = {}) {
28
28
  const limit = deadline(timeoutMs, cancel);
29
29
  let known = [];
30
30
  let receipt = null;
31
+ let found = false;
31
32
  let attempts = 0;
32
33
  const end = (outcome, reason, data = receipt) => {
33
34
  if (holdsKnown(data, known)) return { outcome: "verification_failed", reason: "credential_in_metadata_response", data: null };
34
35
  return { outcome, reason, data: data === null ? null : { ...data, attempts } };
35
36
  };
36
37
  // Once the origin has answered with a valid pending receipt, a deadline
37
- // means the trace is not visible yet, not that the origin is unreachable.
38
+ // means the trace is not visible yet, exactly as when attempts run out.
39
+ // Only a deadline with no valid answer is reported as a connection failure.
40
+ // A deadline while opening an already found trace keeps the timeout reason.
38
41
  const interrupted = () => !limit.timedOut() ? end("cancelled", "cancelled")
39
- : end(receipt === null ? "connection_failed" : "verification_failed", "verification_timeout");
42
+ : receipt === null ? end("connection_failed", "verification_timeout")
43
+ : end("verification_failed", found ? "verification_timeout" : "trace_not_found_within_bounds");
40
44
  try {
41
45
  const sessionResult = await (dependencies.session ?? verifiedSession)({ project: options.project, configDir: options.configDir, cancel: limit.signal });
42
46
  if (limit.signal.aborted) return interrupted();
@@ -58,6 +62,7 @@ export async function runVerify(options, dependencies = {}) {
58
62
  receipt = checked.value;
59
63
  if (holdsKnown(receipt, known)) return end("verification_failed", "credential_in_metadata_response", null);
60
64
  if (checked.found) {
65
+ found = true;
61
66
  if (options.open) {
62
67
  const opened = await openTrace(receipt, { ...options, signal: limit.signal }, dependencies.launch);
63
68
  if (limit.signal.aborted) return interrupted();