commit 3740dba58c6f0b259062da8b3a20a636fb3eefe6
parent b35eeaea94a2260d27924bd88c35a1ddbb1020c3
Author: Florian Dold <dold@taler.net>
Date: Tue, 21 Jul 2026 10:59:56 +0200
util: fix the long-polling flag and stop mutating caller options
The flag was negated, and recomputed after the options object had been
rewritten in place, so the finish events of a request disagreed with its
start event.
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/packages/taler-util/src/observability.ts b/packages/taler-util/src/observability.ts
@@ -57,6 +57,9 @@ export class ObservableHttpClientLibrary implements HttpRequestLibrary {
const cancelator = CancellationToken.create();
let unregisterCancel: (() => void) | undefined = undefined;
+ // Long-polling requests are the ones the caller can cancel, so a
+ // cancellation token is what distinguishes them here.
+ const longPolling = !!opt?.cancellationToken;
if (opt?.cancellationToken) {
unregisterCancel = opt.cancellationToken.onCancelled(cancelator.cancel);
}
@@ -67,11 +70,10 @@ export class ObservableHttpClientLibrary implements HttpRequestLibrary {
when: AbsoluteTime.now(),
type: ObservabilityEventType.HttpFetchStart,
url: url,
- longPolling: !opt?.cancellationToken,
+ longPolling,
});
- const optsWithCancel = opt ?? {};
- optsWithCancel.cancellationToken = cancelator.token;
+ const optsWithCancel = { ...opt, cancellationToken: cancelator.token };
const start = performanceNow();
try {
const res = await this.impl.fetch(url, optsWithCancel);
@@ -83,7 +85,7 @@ export class ObservableHttpClientLibrary implements HttpRequestLibrary {
url,
status: res.status,
durationMs: performanceDelta(start, end),
- longPolling: !opt?.cancellationToken,
+ longPolling,
};
this.oc.observe(event);
return res;
@@ -96,7 +98,7 @@ export class ObservableHttpClientLibrary implements HttpRequestLibrary {
url,
error: getErrorDetailFromException(e),
durationMs: performanceDelta(start, end),
- longPolling: !opt?.cancellationToken,
+ longPolling,
});
throw e;
} finally {