Skip to content

CPU 100% on UDP error !!!! #29436

Closed
Closed

Description

@duongvanba

What version of Bun is running?

1.3.12

What platform is your computer?

Ubuntu

What steps can reproduce the bug?

This code make CPU 100% (and system crash if using single core)

const socket = await Bun.udpSocket({
  socket:{
    error( error) {
      console.error("UDP Socket Error:", error);
    },
  }
});
socket.send("Hello, World!", 41234, "127.0.0.1");

Can you help me fix this, my product crashed at all

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

Activity

  1. github-actions commented on Apr 18, 2026

    @github-actions
    Contributor

    Found 1 possible duplicate issue:

    1. node:dgram emits ECONNREFUSED recv and exits in Bun 1.3.12, but not 1.3.11 #29116

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. duongvanba commented on Apr 18, 2026

    @duongvanba
    Author

    this is not a duplicate problem 👎👎👎👎 DO NOT CLOSE
    This is critical bug

  3. Jarred-Sumner commented on Apr 18, 2026

    @Jarred-Sumner
    Collaborator
  4. robobun commented on Apr 18, 2026

    @robobun
    Collaborator

    ✅ Reproduced — sending to an unreachable UDP port pins CPU at 100% on Linux.

    Root cause: IP_RECVERR queues the ICMP error and raises EPOLLERR, but the error queue was never drained with MSG_ERRQUEUE — plain recvmmsg reports the error without dequeuing it, so epoll_wait busy-loops.

    Fix: → #29473

    The diff is green on every lane that touches it — all Linux test lanes pass, 29436.test.ts passes everywhere, 0 review threads open. CI umbrella is red only on test/js/web/fetch/fetch-http2-client.test.ts (WebKit AtomStringImpl assertion in the HTTP/2 fetch client) and test-http-should-emit-close-when-connection-is-aborted.ts (Windows timeout, failing across builds 53958–53962 on main too). Neither touches UDP or packages/bun-usockets/. Ready for a maintainer to merge.

  5. Jarred-Sumner commented on Apr 19, 2026

    @Jarred-Sumner
    Collaborator

    @robobun submit PR

  6. duongvanba commented on Apr 19, 2026

    @duongvanba
    Author

    Omg so crazy, so no humman here right ? everything done with bot
    Thank BunJS

  7. added 2 commits that reference this issue on Apr 27, 2026
    0a2b057
    2f32c79
  8. added a commit that references this issue on May 4, 2026
    4752d70
  9. robobun commented on Jul 25, 2026

    @robobun
    Collaborator

    Fixed by #29768 (which landed the MSG_ERRQUEUE drain from #29473).

    Verified on main (df84f8db1, Linux x64) with the exact repro — the ICMP error is now drained and surfaced to the error handler, and CPU stays idle instead of spinning at 100%:

    UDP Socket Error: ECONNREFUSED: connection refused, recv
      syscall: "recv",
        errno: -111,
     errqueue: true,
         code: "ECONNREFUSED"
    
    CPU% 4.1
    

    Closing.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions