Skip to content

WebSocketStream unhandled rejection #25077

@sergeysolovev

Description

@sergeysolovev

Version: Deno 1.45.5
OS: Linux

Steps: start a server which accepts a ws connection, not necessary to send anything from the server. Can use this one from another issue I’ve filed, just please comment out the part where it sends tons of messages. Start the client script (below). Exit the server script, in my case the client gets Unexpected EOF error.

Somehow I get unhandled rejection, though in the client code below I can’t see where it pops up from. Is possible it gets thrown and not intercepted somewhere internally?

const wss = new WebSocketStream('ws://localhost:3333/');
const conn = await wss.opened;
const reader = conn.readable.getReader();

addEventListener('unhandledrejection', (event) => {
  event.preventDefault();
  console.log('unhandledrejection', event);
});

wss.closed.then((x) => {
  console.log('closed', x);
}).catch((err) => {
  console.log('err', err);
});

while (true) {
  try {
    const { value, done } = await reader.read();
    if (done) {
      console.log('done');
      break;
    }
    console.log('msg', value);
  } catch (error) {
    console.log('read_loop_error', error);
    break;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlyext/websocketrelated to the ext/websocket crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions