MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / startConnection

Function startConnection

www/js/_hyperscript-max.js:11768–11795  ·  view source on GitHub ↗
(stub)

Source from the content-addressed store, hash-verified

11766 return stub;
11767 }
11768 function startConnection(stub) {
11769 var ac = new AbortController();
11770 stub.abortController = ac;
11771 var fetchOptions = {
11772 method: stub.method,
11773 signal: ac.signal,
11774 headers: Object.assign({}, stub.headers || {})
11775 };
11776 if (stub.withCredentials) {
11777 fetchOptions.credentials = "include";
11778 }
11779 if (stub.lastEventId) {
11780 fetchOptions.headers["Last-Event-ID"] = stub.lastEventId;
11781 }
11782 fetch(stub.url, fetchOptions).then(function(response) {
11783 if (ac.signal.aborted) return;
11784 if (!response.ok) {
11785 throw new Error("SSE connection failed with status " + response.status);
11786 }
11787 stub.retryCount = 0;
11788 dispatch(stub, "open", { type: "open" });
11789 return readStream(stub, response.body.getReader(), ac);
11790 }).catch(function(err) {
11791 if (ac.signal.aborted) return;
11792 dispatch(stub, "error", { type: "error", error: err });
11793 scheduleReconnect(stub);
11794 });
11795 }
11796 async function readStream(stub, reader, ac) {
11797 stub.reader = reader;
11798 var baseDelay = 500;

Callers 2

createStubFunction · 0.70
scheduleReconnectFunction · 0.70

Calls 4

dispatchFunction · 0.70
readStreamFunction · 0.70
scheduleReconnectFunction · 0.70
fetchFunction · 0.50

Tested by

no test coverage detected