镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

possible libuv issue with macos 10.15: empty udp message not registering #30030

Description

@daviehh
  • Version:
    v12.12.0
  • Platform:
    macos catalina/10.15 (19A602)
  • Subsystem:
    n/a

When sending an empty udp message, the message will not be received until another non-empty udp message is received.

Example/Reproduce: (may only affect macos 10.15?)

file server.js

var PORT = 33333;
var HOST = '127.0.0.1';

var dgram = require('dgram');
var server = dgram.createSocket('udp4');

server.on('listening', function() {
  var address = server.address();
 console.log('UDP Server listening on ' + address.address + ':' + address.port);
});

server.on('message', function(message, remote) {
 console.log(remote.address + ':' + remote.port +' - ' + message);
});

server.bind(PORT, HOST);

file client_test.js

var PORT = 33333;
var HOST = '127.0.0.1';

var dgram = require('dgram');


var client = dgram.createSocket('udp4');
var message = Buffer.from('abc');

client.send(message, 0, message.length, PORT, HOST, function(err, bytes) {
  if (err) throw err;
  console.log('UDP message sent to ' + HOST +':'+ PORT);
  client.close();
});

file client_0.js

var PORT = 33333;
var HOST = '127.0.0.1';

var dgram = require('dgram');


var client = dgram.createSocket('udp4');
var message = Buffer.from('');

client.send(message, 0, message.length, PORT, HOST, function(err, bytes) {
  if (err) throw err;
  console.log('UDP message sent to ' + HOST +':'+ PORT);
  client.close();
});

run the server code, then run the client_0.js: no response in server.
followed by running client_test.js: server got empty and the "abc" message.

Activity

  1. added
    dgramIssues and PRs related to UDP and the dgram module.
    on Oct 18, 2019
  2. addaleax commented on Oct 18, 2019

    @addaleax
    Member

    Does this also happen with Node 12.11.1?

  3. daviehh commented on Oct 18, 2019

    @daviehh
    Author

    @addaleax Yes, just tried with the binary using https://nodejs.org/dist/v12.11.1/

  4. added
    macosIssues and PRs related to the macOS platform.
    on Oct 18, 2019
  5. addaleax commented on Oct 18, 2019

    @addaleax
    Member

    /cc @nodejs/platform-macos

    @daviehh Have you tried recreating this with e.g. Python? I’m not on a mac but I have the suspicion that this may actually be just a platform quirk of macOS that we can’t do anything about.

  6. daviehh commented on Oct 18, 2019

    @daviehh
    Author

    @addaleax I have actually tried Python, empty udp message works there:

    receiving:

    import socket
    
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind(("127.0.0.1", 6000))
    
    while True:
        data, addr = sock.recvfrom(1024)
        print("received message:", data)
    

    sending:

    import socket
    
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.sendto(b"", ("127.0.0.1", 6000))
    
  7. lpinca commented on Oct 20, 2019

    @lpinca
    Member

    It seems our test suite also fails due to this on macOS Catalina.

    === release test-dgram-connect-send-empty-buffer ===                          
    Path: parallel/test-dgram-connect-send-empty-buffer
    Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-connect-send-empty-buffer.js
    --- TIMEOUT ---
    === release test-dgram-connect-send-empty-array ===        
    Path: parallel/test-dgram-connect-send-empty-array
    Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-connect-send-empty-array.js
    --- TIMEOUT ---
    === release test-dgram-connect-send-empty-packet ===       
    Path: parallel/test-dgram-connect-send-empty-packet
    Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-connect-send-empty-packet.js
    --- TIMEOUT ---
    === release test-dgram-send-empty-array ===                
    Path: parallel/test-dgram-send-empty-array
    Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-send-empty-array.js
    --- TIMEOUT ---
    === release test-dgram-send-empty-buffer ===               
    Path: parallel/test-dgram-send-empty-buffer
    Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-send-empty-buffer.js
    --- TIMEOUT ---
    === release test-dgram-send-empty-packet ===
    Path: parallel/test-dgram-send-empty-packet
    Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-send-empty-packet.js
    --- TIMEOUT ---
    [03:46|% 100|+ 2791|-   6]: Done
    
  8. daviehh commented on Oct 20, 2019

    @daviehh
    Author

    Thanks! I first noticed this issue with a beta version of another language that uses libuv (julia), so it's likely that it's a libuv bug; is it good for the bug report to be here or is it better to report to libuv? Not sure how to write a simple c code that directly uses libuv to reproduce the issue though.

  9. santigimeno commented on Oct 20, 2019

    @santigimeno
    Member

    Yeah, I've reproduced the issue in libuv. Apparently the message is actually sent (I've checked it with tcpdump) but not received.

  10. santigimeno commented on Oct 20, 2019

    @santigimeno
    Member

    It looks like a problem with kqueue not reporting the event. The python example does not seem to apply to our case as it's waiting on recvfrom syscall.

  11. addaleax commented on Dec 15, 2019

    @addaleax
    Member

    @nodejs/libuv Has anybody reported this to Apple yet? I’m assuming that that’s the thing to do here, no?

  12. bnoordhuis commented on Dec 16, 2019

    @bnoordhuis
    Member

    Yes... except sending a bug report to Apple is like throwing matter into a black hole: it disappears and is never seen again.

  13. indutny commented on Dec 17, 2019

    @indutny
    Member

    I have a channel to get some additional information from Apple given the bug report number. Has anyone reported it?

  14. indutny commented on Dec 17, 2019

    @indutny
    Member

    Oh... I just realized that I might have reported this in 2014 and provided a fix. Here is a repo (by other person) that reproduces the issue using outdated libuv version: https://github.com/misterdjules/udp-empty-dgram-repro

  15. 13 remaining items

  16. Keno commented on Mar 4, 2020

    @Keno

    Apple has told me that they have identified a fix and will ship it in a future OS update, but have not provided any further details than that.

  17. AshCripps commented on Mar 4, 2020

    @AshCripps
    Member

    @Keno At least that something, thanks for letting us know!

  18. richardlau commented on Mar 4, 2020

    @richardlau
    Member

    #22546 (Can only find the PR to remove the skip)

    The skip is very old and was added in the old repository (see #30030 (comment)).

  19. MylesBorins commented on Mar 11, 2020

    @MylesBorins
    Contributor

    I'm seeing multiple instances of our test suite not respecting the mark of flaky in these tests, any idea what's up?

    https://ci.nodejs.org/job/node-test-commit-osx/32536/#showFailuresLink

    nvm failure is due to test-timers-blocking-callback

  20. lpinca commented on Mar 25, 2020

    @lpinca
    Member

    The issue seems to be fixed in macOS 10.15.4

  21. BethGriggs commented on Nov 17, 2021

    @BethGriggs
    Member

    Closing as based on the comments this is fixed, and the tests are no longer skipped in CI on macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.dgramIssues and PRs related to UDP and the dgram module.macosIssues and PRs related to the macOS platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions