So if I put releaseLock at the end this seems to unlock the stdin however it still gives me the error that even though the stream isn't locked anymore writer wont write anymore
async writeToStdin(data: string): Promise<void> {
console.log("Writing to stdin");
const encoder = new TextEncoder();
const encoded = encoder.encode(data);
console.log(this.stdin);
const writer = await this.stdin.getWriter();
console.log(writer);
await writer.write(encoded);
writer.close();
writer.releaseLock();
}
async writeToStdin(data: string): Promise<void> {
console.log("Writing to stdin");
const encoder = new TextEncoder();
const encoded = encoder.encode(data);
console.log(this.stdin);
const writer = await this.stdin.getWriter();
console.log(writer);
await writer.write(encoded);
writer.close();
writer.releaseLock();
}
Writing to stdin
WritableStream { locked: false }
WritableStreamDefaultWriter {
closed: Promise { undefined },
desiredSize: 0,
ready: Promise { undefined }
}
error: Uncaught (in promise) TypeError: The stream is closing or is closed.
await writer.write(encoded);
Writing to stdin
WritableStream { locked: false }
WritableStreamDefaultWriter {
closed: Promise { undefined },
desiredSize: 0,
ready: Promise { undefined }
}
error: Uncaught (in promise) TypeError: The stream is closing or is closed.