Skip to content

Commit 553175f

Browse files
author
Ghita Filali
committed
fix(message): wait for bounded provider sends
1 parent 45703e7 commit 553175f

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎src/infra/outbound/message-gateway-options.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
import { describe, expect, it } from "vitest";
44
import { MAX_TIMER_TIMEOUT_MS } from "../../shared/number-coercion.js";
55
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js";
6-
import { resolveOutboundMessageGatewayOptions } from "./message-gateway-options.js";
6+
import {
7+
DEFAULT_OUTBOUND_MESSAGE_GATEWAY_TIMEOUT_MS,
8+
resolveOutboundMessageGatewayOptions,
9+
} from "./message-gateway-options.js";
710

811
describe("resolveOutboundMessageGatewayOptions", () => {
12+
it("waits long enough for bounded provider sends to finish", () => {
13+
expect(resolveOutboundMessageGatewayOptions().timeoutMs).toBe(
14+
DEFAULT_OUTBOUND_MESSAGE_GATEWAY_TIMEOUT_MS,
15+
);
16+
});
17+
918
it("clamps oversized gateway timeouts", () => {
1019
expect(
1120
resolveOutboundMessageGatewayOptions({ timeoutMs: Number.MAX_SAFE_INTEGER }).timeoutMs,

‎src/infra/outbound/message-gateway-options.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
type GatewayClientName,
99
} from "../../utils/message-channel.js";
1010

11+
export const DEFAULT_OUTBOUND_MESSAGE_GATEWAY_TIMEOUT_MS = 75_000;
12+
1113
/** Raw gateway options accepted by outbound message senders. */
1214
export type OutboundMessageGatewayOptionsInput = {
1315
url?: string;
@@ -30,7 +32,10 @@ export function resolveOutboundMessageGatewayOptions(gateway?: OutboundMessageGa
3032
return {
3133
url,
3234
token: gateway?.token,
33-
timeoutMs: resolveTimerTimeoutMs(gateway?.timeoutMs, 10_000),
35+
timeoutMs: resolveTimerTimeoutMs(
36+
gateway?.timeoutMs,
37+
DEFAULT_OUTBOUND_MESSAGE_GATEWAY_TIMEOUT_MS,
38+
),
3439
clientName,
3540
clientDisplayName: gateway?.clientDisplayName,
3641
mode,

0 commit comments

Comments
 (0)