lowercasebtw
lowercasebtw•3w ago

Stupid Broken Pipe

how do I handle this without the thing just quitting, I've put try catches everywhere
No description
9 Replies
lowercasebtw
lowercasebtw•3w ago
I need this to not quit on these kinds of errors its annoying why is there no method to check if its writable at the time or whatever, ughhhh i'm also supossidely/most definitely losing data/packets somehow and I can't have that happening
ioB
ioB•3w ago
can you share code
lowercasebtw
lowercasebtw•2w ago
Gimme a second (few mins) Not at pc rn Ugh
lowercasebtw
lowercasebtw•2w ago
No description
lowercasebtw
lowercasebtw•2w ago
async listen() {
this.server = new Server({
hostname: this.address,
port: this.port,
chunkSize: MAX_BYTES_ALLOWED
});

this.server.on("listen", () => Logger.log(Level.INFO, `Listening on ${this.address}:${this.port}`));

this.server.on("connect", (client: Client) => {
const connection = new ClientConnection(client);
this.connections.set(client, connection);
Logger.log(Level.INFO, `Client ${connection.id} connected!`);

client.addListener("receive", async (_, packet: Packet) => {
const reader = new ByteReader(packet.data);
reader.read(Type.VAR_INT) as number; // TODO: packet length?
const packet_id = reader.read(Type.VAR_INT) as number;
await connection.handle(this, reader, packet, packet_id);
});

client.addListener("close", async () => {
Logger.log(Level.INFO, `Client ${connection.id} disconnected!`);
// TODO: cleanup?
await connection.close();
this.connections.delete(client);
});
});

await this.server.listen();
}
async listen() {
this.server = new Server({
hostname: this.address,
port: this.port,
chunkSize: MAX_BYTES_ALLOWED
});

this.server.on("listen", () => Logger.log(Level.INFO, `Listening on ${this.address}:${this.port}`));

this.server.on("connect", (client: Client) => {
const connection = new ClientConnection(client);
this.connections.set(client, connection);
Logger.log(Level.INFO, `Client ${connection.id} connected!`);

client.addListener("receive", async (_, packet: Packet) => {
const reader = new ByteReader(packet.data);
reader.read(Type.VAR_INT) as number; // TODO: packet length?
const packet_id = reader.read(Type.VAR_INT) as number;
await connection.handle(this, reader, packet, packet_id);
});

client.addListener("close", async () => {
Logger.log(Level.INFO, `Client ${connection.id} disconnected!`);
// TODO: cleanup?
await connection.close();
this.connections.delete(client);
});
});

await this.server.listen();
}
Doctor 🤖
Doctor 🤖•2w ago
Is this all the code?
lowercasebtw
lowercasebtw•2d ago
its enough to reproduce the error minus a few spots the issue is with this lib from "https://deno.land/x/tcp_socket@0.0.2/mods.ts"; @lino-levan .
marvinh.
marvinh.•2d ago
@lowercasebtw Can you file an issue for this here https://github.com/denoland/deno/issues/new?template=bug_report.md ? The developers all hang out on GitHub and the best way to get bugs resolved is to post an issue over there.
lowercasebtw
lowercasebtw•2d ago
alright