Skip to content

Classify native network errors using the selected operating system #508

Closed

Description

@LunaStev

Reproduced problem

std/net/error.wave::net_error_from_native combines Linux, BSD/Darwin and Winsock error numbers in one unconditional table. Numbers overlap across OSes, so an unrelated error can be reported as retryable or as a refused connection.

On Linux, EDEADLK is 35 and ENODATA is 61. This program prints deadlock=3 no_data=5: NET_ERROR_WOULD_BLOCK and NET_ERROR_REFUSED respectively.

import("std::net::error")::{NetError, net_error_from_native};
fun main() -> i32 {
    var deadlock: NetError = net_error_from_native(-35);
    var no_data: NetError = net_error_from_native(-61);
    println("deadlock={} no_data={}", deadlock.kind, no_data.kind);
    return 0;
}

Build/run with the repository std installed in the test HOME. Compare the host constants with python3 -c 'import errno; print(errno.EDEADLK, errno.ENODATA)'. Genuine Linux EAGAIN (11) and ECONNREFUSED (111) must continue mapping correctly.

Scope and acceptance

  • Use target-gated mappings for Linux, macOS, FreeBSD and Windows rather than combining numeric aliases from different OSes.
  • Preserve native_code exactly and return NET_ERROR_OTHER for codes without an applicable category.
  • Add table-driven Wave regression checks for recognized codes, cross-OS collisions and unknown values.
  • Keep the public result/error structures and existing category constants unchanged.
  • Use existing target attributes and native constants; no libc FFI or new dependency is needed for this mapping.

This is a good first issue: the change is a small pure classification function, and tests need no live network connection. Verify each OS table against its own constants rather than inferring them from Linux.

Audited on canonical master 0c67f4cc0c3946cbf708c11ef79db927ec8f054e (same source tree as #502 head). Executable reproductions used Fedora Linux amd64, Wave 0.2.1-pre-beta-dev, LLVM 21.1.8.

Activity

  1. added
    bug
    good first issue
    needs testing
    cross-platform
    on Sep 7, 2026
  2. self-assigned this
    on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcross-platformgood first issueneeds testing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions