deno icon indicating copy to clipboard operation
deno copied to clipboard

feat(node): ref/unref for udp

Open CosminPerRam opened this issue 1 year ago • 5 comments
trafficstars

I attempted on adding ref/unref for UDP. I do not expect this to be merged (as I do not think what I've done is exactly what is needed for it), but suggestions and directions would be gladly appreciated.

Related:

  • Issue regarding this: Error: Not implemented: udp.UDP.prototype.unref #20138
  • cargo test integration::js_unit_tests::net_test yields OK.
  • Didn't ran format and lint as I had problems running them (would format other files).

CosminPerRam avatar Dec 09 '23 00:12 CosminPerRam

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Dec 09 '23 00:12 CLAassistant

Bump, any thoughts?

CosminPerRam avatar Dec 12 '23 15:12 CosminPerRam

@littledivy please review

bartlomieju avatar Dec 13 '23 14:12 bartlomieju

Sorry for the linting issues, had some troubles running it at first, will fix asap when I'll get on my computer.

CosminPerRam avatar Dec 13 '23 14:12 CosminPerRam

Hope I don't miss anything, but there is no cli/tests/unit_node/dgram_test.ts file, so I've created it.

udp ref and unref fails with

[dgram_test 009.80] [node/dgram] udp ref and unref => ./cli/tests/unit_node/dgram_test.ts:9:6
[dgram_test 009.80] error: Leaking async ops:
[dgram_test 009.80]   - 1 async operation to receive a datagram message via UDP was started in this test, but never completed. This is often caused by not awaiting the result of `Deno.DatagramConn#receive` call, or not breaking out of a for await loop looping over a `Deno.DatagramConn`. 

udp unref hangs indefinetly (test integration::node_unit_tests::dgram_test has been running for over 60 seconds)

CosminPerRam avatar Dec 16 '23 02:12 CosminPerRam

@littledivy @CosminPerRam it appears there's still a failing test that leaks ops. Can you please take a look at it?

bartlomieju avatar Jan 01 '24 22:01 bartlomieju

Unfortunately this beats me, @littledivy could you please take care of it (some afterwards explanations would be appreciated)?

CosminPerRam avatar Jan 03 '24 14:01 CosminPerRam

@CosminPerRam I opened https://github.com/denoland/deno/pull/21777 with a different implementation that fixes bugs in this approach. The major one being that the promises returned by this.#listener are not ref/unrefable because they wrap the actual async op call.

littledivy avatar Jan 03 '24 15:01 littledivy

Thanks, I will close this PR as that one superseeds this one.

CosminPerRam avatar Jan 03 '24 15:01 CosminPerRam