Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions packages/cli/tests/repl-execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ describe("REPL execution: reopening one history", () => {
}
});

it("X2: a refused reconstruction leaves nothing of itself behind", function* () {
it("X2: an unprojectable history refuses atomically and leaves nothing behind", function* () {
const settled = yield* referenceEvents();
const holder = execution([settled[0], settled[0], ...settled.slice(1)]);
const asked = yield* countAsked();
Expand All @@ -589,17 +589,10 @@ describe("REPL execution: reopening one history", () => {
expect(holder.stream.onAppend).toBe(null);
expect(asked.calls).toBe(0);
const before = (yield* readAll(holder)).length;
expect(before).toBe(settled.length + 1);
yield* holder.stream.append(settled[settled.length - 1]);
expect((yield* readAll(holder)).length).toBe(before + 1);
});

it("X2: a history this version cannot project refuses before anything runs", function* () {
const settled = yield* referenceEvents();
const holder = execution([settled[0], settled[0], ...settled.slice(1)]);

expect(refusal(yield* openReplSession(options(holder))).message).toContain("a second entry");
expect((yield* holder.stream.readAll()).length).toBe(settled.length + 1);
});
});

describe("REPL execution: pausing expansion", () => {
Expand Down
12 changes: 10 additions & 2 deletions packages/web/tests/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function useConnection(
let version = 0;
let waiting: ((value: void) => void) | undefined;
const ended = withResolvers<string>();
let termination: string | undefined;

const advance = (): void => {
version += 1;
Expand All @@ -105,11 +106,13 @@ export function useConnection(
advance();
};
const onError = (error: Error): void => {
ended.resolve(`error:${error.message}`);
termination ??= `error:${error.message}`;
ended.resolve(termination);
advance();
};
const onClose = (): void => {
ended.resolve("close");
termination ??= "close";
ended.resolve(termination);
advance();
};

Expand Down Expand Up @@ -161,6 +164,11 @@ export function useConnection(
buffer = parsed.rest;
return parsed.response;
}
if (termination !== undefined) {
throw new Error(
`incomplete HTTP response after ${termination}; buffered ${buffer.length} characters; prefix ${JSON.stringify(buffer.slice(0, 160))}`,
);
}
yield* untilAfter(seen);
}
},
Expand Down
Loading
Loading