Skip to content

Commit

Permalink
refactor: move debug readLogStream back to it's own file
Browse files Browse the repository at this point in the history
  • Loading branch information
xynydev committed Apr 22, 2024
1 parent ab2e868 commit d7bba7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/lib/ts/misc/logStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ export async function createLogStream(

export async function readLogStream(res: Response, onNewValue: (value: string) => void) {
const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();
console.log(reader);
// eslint-disable-next-line no-constant-condition
while (true) {
console.log("reading...");
const { value, done } = await reader.read();
console.log("received: ", value);
if (done) break;
onNewValue(value);
}
console.log("DONE!");
}
18 changes: 2 additions & 16 deletions src/routes/new/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,12 @@
}
});
console.log(res);
const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();
console.log(reader);
// eslint-disable-next-line no-constant-condition
while (true) {
console.log("reading...");
const { value, done } = await reader.read();
console.log("received: ", value);
if (done) break;
readLogStream(res, (value) => {
log = [...log, value];
if (value.includes("DONE!")) {
setupStep = "cosign";
}
}
console.log("DONE!");
// readLogStream(res, (value) => {
// log = [...log, value];
// if (value.includes("DONE!")) {
// setupStep = "cosign";
// }
// });
});
}

async function setupCosign() {
Expand Down

0 comments on commit d7bba7a

Please sign in to comment.