Skip to content

Node PHP.wasm DNS functions return hardcoded empty results #4171

Description

@chubes4

Description

The PHP.wasm DNS polyfill added after #1042 defines dns_check_record(), dns_get_record(), and dns_get_mx(), but all three still return hardcoded failure/empty results and emit warnings. In the Node runtime this is a behavioral incompatibility rather than an unavailable capability: packages/php-wasm/node/src/lib/wasm-user-space.ts already bridges Node DNS for gethostbyname().

This prevents WordPress and plugin code from detecting real A/MX records. Downstream examples include email validation, hosting-provider detection, site profiling, security scanning, and HTTP tests.

Reproduction

Run PHP 8.4 through the Node PHP.wasm runtime:

var_dump(dns_check_record('wordpress.org', 'A'));
var_dump(dns_get_record('wordpress.org', DNS_A));
var_dump(dns_get_mx('wordpress.org', $hosts, $weights), $hosts, $weights);

Observed:

bool(false)
array(0) {}
bool(false)

The implementation explicitly emits:

  • dns_check_record() always returns false in PHP.wasm.
  • dns_get_record() always returns an empty array in PHP.wasm.
  • dns_get_mx() always returns an empty array in PHP.wasm.

Source: packages/php-wasm/compile/php-wasm-dns-polyfill/dns_polyfill.c.

Expected behavior

In the Node runtime, resolve requested DNS records through Node's DNS APIs and return PHP-compatible result shapes for at least A, AAAA, CNAME, MX, NS, TXT, SRV, CAA, and PTR records. Preserve deterministic false/empty behavior when resolution fails. Browser behavior can remain explicitly unsupported until it has a resolver transport.

Add Node integration coverage asserting real record shapes and aliases (checkdnsrr, getmxrr) rather than only function existence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions