Skip to content

Commit 1c3394f

Browse files
committed
conat: fix llm test
1 parent 7c0ff55 commit 1c3394f

File tree

5 files changed

+6
-17
lines changed

5 files changed

+6
-17
lines changed

src/packages/backend/conat/test/llm.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import "@cocalc/backend/conat";
1212

1313
import { init, close } from "@cocalc/conat/llm/server";
1414
import { llm } from "@cocalc/conat/llm/client";
15+
import { before, after } from "@cocalc/backend/conat/test/setup";
16+
17+
beforeAll(before);
1518

1619
describe("create an llm server, client, and stub evaluator, and run an evaluation", () => {
1720
// define trivial evaluate
@@ -82,3 +85,5 @@ describe("test an evaluate that throws an error half way through", () => {
8285
await close();
8386
});
8487
});
88+
89+
afterAll(after);

src/packages/conat/llm/client.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { getEnv } from "@cocalc/conat/client";
66
import type { ChatOptions } from "@cocalc/util/types/llm";
77
import { isValidUUID } from "@cocalc/util/misc";
88
import { llmSubject } from "./server";
9-
import { waitUntilConnected } from "@cocalc/conat/util";
109

1110
export async function llm(options: ChatOptions): Promise<string> {
1211
if (!options.system?.trim()) {
@@ -22,7 +21,6 @@ export async function llm(options: ChatOptions): Promise<string> {
2221
let lastSeq = -1;
2322
const { cn } = await getEnv();
2423
let { stream, ...opts } = options;
25-
await waitUntilConnected();
2624
for await (const resp of await cn.requestMany(subject, opts, {
2725
maxWait: opts.timeout ?? 1000 * 60 * 10,
2826
})) {

src/packages/conat/tiered-storage/client.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type { Info, Command } from "./server";
66
import { tieredStorageSubject } from "./server";
77
import { getEnv, getLogger } from "@cocalc/conat/client";
88
import { type Location } from "@cocalc/conat/types";
9-
import { waitUntilConnected } from "@cocalc/conat/util";
109
import { reuseInFlight } from "@cocalc/util/reuse-in-flight";
1110
import { delay } from "awaiting";
1211

@@ -84,7 +83,6 @@ export const waitUntilReady = reuseInFlight(
8483
logger.debug("waitUntilReady", location);
8584
let d = 1000;
8685
while (true) {
87-
await waitUntilConnected();
8886
const locationInfo = await info(location);
8987
const active = lastActive(locationInfo);
9088
if (locationInfo.nats.kv != null || locationInfo.nats.stream != null) {

src/packages/conat/time.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import { timeClient } from "@cocalc/conat/service/time";
4141
import { reuseInFlight } from "@cocalc/util/reuse-in-flight";
4242
import { getClient } from "@cocalc/conat/client";
4343
import { delay } from "awaiting";
44-
import { waitUntilConnected } from "./util";
4544

4645
// we use exponential backoff starting with a short interval
4746
// then making it longer
@@ -97,7 +96,6 @@ export const getSkew = reuseInFlight(async (): Promise<number> => {
9796
return skew;
9897
}
9998
try {
100-
await waitUntilConnected();
10199
const start = Date.now();
102100
const client = getClient();
103101
const tc = timeClient(client);

src/packages/conat/util.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,4 @@ export const getMaxPayload = reuseInFlight(async () => {
188188
}
189189
});
190190

191-
export const waitUntilConnected = reuseInFlight(async () => {
192-
const nc = (await getConnection()) as any;
193-
if (nc.protocol?.connected) {
194-
return;
195-
}
196-
console.log("NATS waitUntilConnected: waiting...");
197-
while (!nc.protocol?.connected) {
198-
await delay(500);
199-
}
200-
console.log("NATS waitUntilConnected: connected");
201-
});
191+
export const waitUntilConnected = reuseInFlight(async () => {});

0 commit comments

Comments
 (0)