Skip to content

Commit

Permalink
handle closed datex stream
Browse files Browse the repository at this point in the history
  • Loading branch information
benStre committed Feb 11, 2024
1 parent 2b380a5 commit fcd9f14
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions types/stream.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ReadableStream } from "../runtime/runtime.ts";
import { Pointer } from "../runtime/pointers.ts";
import type { datex_scope } from "../utils/global_types.ts";
import { TypedArray } from "../utils/global_values.ts";
import { StreamConsumer } from "./abstract_types.ts";
import { Logger } from "../utils/logger.ts";

Expand Down Expand Up @@ -37,7 +36,12 @@ export class Stream<T = ArrayBuffer> implements StreamConsumer<T> {
}
}

this.controller?.enqueue(chunk);
try {
this.controller?.enqueue(chunk);
}
catch (e) {
console.error("stream write error", e);
}
}

async pipe(in_stream:Stream<T>|ReadableStream<T>, scope?: datex_scope) {
Expand All @@ -52,6 +56,7 @@ export class Stream<T = ArrayBuffer> implements StreamConsumer<T> {

close() {
this.controller?.close()
this.controller = undefined;
}

getReader() {
Expand Down

0 comments on commit fcd9f14

Please sign in to comment.