Skip to content

Commit 5e10848

Browse files
fix: clarify provider quota errors
1 parent 5f2c202 commit 5e10848

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/commands/agent-via-gateway.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ async function waitForGatewayCall(expectedCalls = 1) {
180180
expect(callGateway).toHaveBeenCalledTimes(expectedCalls);
181181
}
182182

183+
function createDeferredVoid() {
184+
let resolve!: () => void;
185+
const promise = new Promise<void>((value) => {
186+
resolve = value;
187+
});
188+
return { promise, resolve };
189+
}
190+
183191
function mockMessages(mock: unknown): string[] {
184192
const calls = (mock as { mock?: { calls?: unknown[][] } }).mock?.calls ?? [];
185193
return calls.map(([message]) => String(message));
@@ -1112,6 +1120,7 @@ describe("agentCliCommand", () => {
11121120
it("passes SIGTERM abort signals into local agent runs", async () => {
11131121
await withTempStore(async () => {
11141122
const signals = createSignalProcess();
1123+
const abortListenerAttached = createDeferredVoid();
11151124
agentCommand.mockImplementationOnce(async (opts: { abortSignal?: AbortSignal }) => {
11161125
expect(opts.abortSignal).toBeInstanceOf(AbortSignal);
11171126
return await new Promise((_, reject) => {
@@ -1124,13 +1133,15 @@ describe("agentCliCommand", () => {
11241133
},
11251134
{ once: true },
11261135
);
1136+
abortListenerAttached.resolve();
11271137
});
11281138
});
11291139

11301140
const run = agentCliCommand({ message: "hi", to: "+1555", local: true }, runtime, {
11311141
process: signals.processLike,
11321142
});
11331143
await waitForAgentCommandCall();
1144+
await abortListenerAttached.promise;
11341145
signals.emit("SIGTERM");
11351146

11361147
await run;
@@ -1144,6 +1155,7 @@ describe("agentCliCommand", () => {
11441155
it("exits for local runs that resolve after SIGTERM aborts them", async () => {
11451156
await withTempStore(async () => {
11461157
const signals = createSignalProcess();
1158+
const abortListenerAttached = createDeferredVoid();
11471159
agentCommand.mockImplementationOnce(async (opts: { abortSignal?: AbortSignal }) => {
11481160
return await new Promise((resolve) => {
11491161
opts.abortSignal?.addEventListener(
@@ -1156,13 +1168,15 @@ describe("agentCliCommand", () => {
11561168
},
11571169
{ once: true },
11581170
);
1171+
abortListenerAttached.resolve();
11591172
});
11601173
});
11611174

11621175
const run = agentCliCommand({ message: "hi", to: "+1555", local: true }, runtime, {
11631176
process: signals.processLike,
11641177
});
11651178
await waitForAgentCommandCall();
1179+
await abortListenerAttached.promise;
11661180
signals.emit("SIGTERM");
11671181

11681182
await expect(run).resolves.toBeUndefined();

0 commit comments

Comments
 (0)