Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket memory leaks #27156

Open
zxch3n opened this issue Nov 29, 2024 · 0 comments
Open

WebSocket memory leaks #27156

zxch3n opened this issue Nov 29, 2024 · 0 comments

Comments

@zxch3n
Copy link

zxch3n commented Nov 29, 2024

Version: Deno 2.1.2

const kind = await op_ws_next_event(rid);

This line will wait even if the connection is closed locally.

Running the following code may reproduce the issue unstablely.

Deno.test("ws leak", async () => {
  const ws = new WebSocket(`validTarget`);
  await new Promise((resolve, reject) => {
    ws.addEventListener("open", resolve);
  });
  ws.close();
});

Run deno test would return the following error sometimes:

error: Leaks detected:
  - "serverWebSocket" was created during the test, but not cleaned up during the test. Close the resource before the end of the test.
  - An async operation to receive the next message on a WebSocket was started in this test, but never completed. This is often caused by not closing a `WebSocket` or `WebSocketStream`. The operation was started here:
    at op_ws_next_event (ext:core/00_infra.js:250:13)
    at WebSocket.[[[eventLoop]]] (ext:deno_websocket/01_websocket.js:431:26)
    at eventLoopTick (ext:core/01_core.js:175:7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant