Skip to content

Commit c67a005

Browse files
fix(server): read GitHub's stream end as the flat outcome it sends
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0f18c01 commit c67a005

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

‎packages/source-control-github/src/server/gitHubPullRequestEvents.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ it.effect("follows a pull request across a refused app token, reconnects, and re
7373
new Response(
7474
sse(
7575
["com.github.pull_request.head.changed.v1", "{}"],
76-
["github.stream.end", JSON.stringify({ outcome: "reconnect" })],
76+
["github.stream.end", '{"outcome":"reconnect","reason":"shutdown"}'],
7777
),
7878
),
7979
() =>
8080
new Response(
81-
sse(["github.stream.end", JSON.stringify({ data: { outcome: "subscription_ended" } })]),
81+
sse(["github.stream.end", '{"outcome":"subscription_ended","reason":"expired"}']),
8282
),
8383
() => new Response(": heartbeat\n\n"),
8484
];

‎packages/source-control-github/src/server/gitHubPullRequestEvents.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ const Subscription = Schema.Struct({
3030
});
3131
const decodeSubscription = Schema.decodeUnknownOption(Schema.fromJsonString(Subscription));
3232

33-
const Outcome = Schema.Struct({ outcome: Schema.optional(Schema.String) });
3433
const decodeStreamEnd = Schema.decodeUnknownOption(
35-
Schema.fromJsonString(Schema.Union([Schema.Struct({ data: Outcome }), Outcome])),
34+
Schema.fromJsonString(Schema.Struct({ outcome: Schema.String })),
3635
);
3736

3837
/**
@@ -45,10 +44,7 @@ type Ending = "reconnect" | "dropped" | "renew" | "personal" | "stop";
4544
const endingOf = (data: string): Ending =>
4645
Option.match(decodeStreamEnd(data), {
4746
onNone: () => "reconnect",
48-
onSome: (end) =>
49-
("data" in end ? end.data.outcome : end.outcome) === "subscription_ended"
50-
? "renew"
51-
: "reconnect",
47+
onSome: ({ outcome }) => (outcome === "subscription_ended" ? "renew" : "reconnect"),
5248
});
5349

5450
export interface PullRequestEventsInput {

0 commit comments

Comments
 (0)