Skip to content

Commit 506bf8d

Browse files
committed
Remove example code from fetch.ts
1 parent f0f6120 commit 506bf8d

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

src/fetch.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,6 @@ export interface FetchEventSourceInit extends RequestInit {
5252
fetch?: typeof fetch;
5353
}
5454

55-
class RetriableError extends Error { }
56-
class FatalError extends Error { }
57-
58-
fetchEventSource('/api/sse', {
59-
async onopen(response) {
60-
response.ok
61-
if (response.status === 429) {
62-
throw new RetriableError();
63-
}
64-
},
65-
onmessage(msg) {
66-
if (msg.event === 'FatalError') {
67-
throw new FatalError(msg.data);
68-
}
69-
},
70-
onclose() {
71-
// if the server closes the connection unexpectedly, retry:
72-
throw new RetriableError();
73-
},
74-
onerror(err) {
75-
if (err instanceof FatalError) {
76-
throw err; // rethrow to stop the operation
77-
} else {
78-
// do nothing to automatically retry. You can also return
79-
// a specific retry interval instead.
80-
}
81-
}
82-
});
83-
8455
export function fetchEventSource(input: RequestInfo, {
8556
signal: inputSignal,
8657
headers: inputHeaders,
@@ -158,7 +129,6 @@ export function fetchEventSource(input: RequestInfo, {
158129

159130
await parseResponse(response);
160131

161-
// if the event stream closes
162132
onclose?.();
163133
dispose();
164134
resolve();

0 commit comments

Comments
 (0)