Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Phone web app yamux: the phone never sends GoAway(removed)

Bugfixer 23d885ba0d667
diff --git a/src/lib/e2e/yamux.test.ts b/src/lib/e2e/yamux.test.ts
index ac15c22cf3..85cd19ffcb 100644
--- a/src/lib/e2e/yamux.test.ts
+++ b/src/lib/e2e/yamux.test.ts
@@ -6,6 +6,7 @@ import {
decodeFrame,
encodeFrame,
GO_AWAY,
+ goAwayFrame,
INITIAL_WINDOW,
MAX_DATA_PAYLOAD,
Mux,
@@ -272,4 +273,23 @@ describe("the browser mux, GoAway(removed)", () => {
mux.receive({ type: 3, flags: 0, streamId: 0, length: GO_AWAY.normal });
expect(codes).toEqual([GO_AWAY.normal]);
});
+
+ it("the phone never sends GoAway(3); its other codes and the computer's GoAway(3) still go out", () => {
+ const sent = (role: Role, code: number) => {
+ const frames: Frame[] = [];
+ const mux = new Mux(role, { send: (frame) => frames.push(frame), data: () => {}, ended: () => {}, reset: () => {}, writable: () => {} });
+ try {
+ mux.goAway(code);
+ } catch (error) {
+ return { frames, error };
+ }
+ return { frames, error: undefined };
+ };
+ const refused = sent("phone", GO_AWAY.removed);
+ expect(refused.error).toBeInstanceOf(YamuxError);
+ expect(refused.frames).toEqual([]);
+ expect(sent("phone", GO_AWAY.normal).frames).toEqual([goAwayFrame(GO_AWAY.normal)]);
+ expect(sent("phone", GO_AWAY.protocol).frames).toEqual([goAwayFrame(GO_AWAY.protocol)]);
+ expect(sent("computer", GO_AWAY.removed).frames).toEqual([goAwayFrame(GO_AWAY.removed)]);
+ });
});
diff --git a/src/lib/e2e/yamux.ts b/src/lib/e2e/yamux.ts
index 44d699a64b..f466cd650d 100644
--- a/src/lib/e2e/yamux.ts
+++ b/src/lib/e2e/yamux.ts
@@ -232,6 +232,7 @@ export class Mux {
}
goAway(code: number = GO_AWAY.normal): void {
+ if (this.role === "phone" && code === GO_AWAY.removed) throw new YamuxError("phone_removed");
this.#localGoneAway = true;
this.#events.send(goAwayFrame(code));
}