MatrixAI / js-mdns

Multicast DNS Stack for TypeScript/JavaScript Applications
https://matrixai.github.io/js-mdns/
Apache License 2.0
0 stars 0 forks source link

`Socket.prototype._handle` is deprecated` warning is caused by `MDNS.ts` #42

Open CMCDragonkai opened 1 month ago

CMCDragonkai commented 1 month ago

Describe the bug

Inside MDNS.ts, it's using _handle in a few places. In particular:

        if (platform === 'linux' && disableLinuxMulticastAllOption) {
          socketUtils.disableSocketMulticastAll(
            (unicastSocket as any)._handle.fd,
          );
        }
          if (platform === 'linux' && disableLinuxMulticastAllOption) {
            socketUtils.disableSocketMulticastAll((socket as any)._handle.fd);
          }

The usage of _handle in the Socket prototype causes warnings.

It looks like this in PK CLI:

(node:500471) [DEP0112] DeprecationWarning: Socket.prototype._handle is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)

Right after starting the agent.

Find an alternative way to do the above, or we need some way of disabling the warning? This is some sort of internal property right?

Apparently Node allows disabling warnings on startup.

To Reproduce

  1. Run Polykey-CLI polykey agent start
  2. Observe warning in the terminal

Expected behavior

No warnings should occur.

Additional context

Notify maintainers

@amydevs

linear[bot] commented 1 month ago

ENG-394 `Socket.prototype._handle` is deprecated` warning is caused by `MDNS.ts`

CMCDragonkai commented 1 month ago

One way to get around this warning is potentially doing all the work in the C++ level? One way to do this is pass the reference to the JS socket object to the native code side, and get the native code to do the necessary referencing of the underlying FD.

Also can we start changing all our native code to Rust to align with js-quic and js-exec? I know js-db is still pending, but it's usually better.

Look at node native code docs as to how to directly interact with socket objects.