lib: throws when invalid hex string in http request by juanarbol · Pull Request #45173 · nodejs/node

I tried to reproduce the same using net instead http but failed.

const net = require("net");
const s = net.createConnection(8000);
s.on("connect", () => {
    s.write("1", "hex");
});

net just discards the incomplete hex char.

Should we aim to be consistent?

Update:
I'm able to reproduce also with net now:

const net = require("net");
const s = net.createConnection(8000);
s.on("connect", () => {
    s.cork()
    s.write("a")
    s.write("1", "hex");
    s.uncork()
});

Seems writev aborts wheres write ignores chars.

As this is not specific to HTTP I would vote for a more generic solution like throwing a JS exception in C++ or ignore invalid chars (likely also in C++).