bytecodealliance / jco

JavaScript toolchain for working with WebAssembly Components
https://bytecodealliance.github.io/jco/
Apache License 2.0
642 stars 65 forks source link

[preview2-shim] OutgoingRequest.setAuthority rejects ports >9999 #460

Closed dicej closed 4 months ago

dicej commented 4 months ago

I'm using jco to run tests for .NET's new WASIp2 support, and have found that calling set-authority on an outgoing-request with a port number greater than 9999 fails: https://github.com/bytecodealliance/jco/blob/d7ec53f02ce12753dcc6f7f66ecd242259b99912/packages/preview2-shim/lib/nodejs/http.js#L265. That's a problem for my tests, because I'm using Node's http.Server.listen with a port of zero (i.e. let the system select an unused port, which normally results in a port higher than 9999).

What's the rationale for that restriction? The docs say set-authority should only return an error if the specified string is syntactically invalid: https://github.com/WebAssembly/wasi-http/blob/a81c61fc584278f801393b22289840a439e51f50/wit/types.wit#L308-L312, which doesn't seem to apply here.