diff --git a/benchmarks/operations/benchmark.js b/benchmarks/operations/benchmark.js index 0c36f5422..8961b6093 100644 --- a/benchmarks/operations/benchmark.js +++ b/benchmarks/operations/benchmark.js @@ -30,6 +30,10 @@ const modules = [ module: "http-request", name: "Outgoing HTTP request (`http.request`)", }, + { + module: "undici", + name: "Outgoing HTTP request (`undici.request`)", + }, ]; (async () => { diff --git a/benchmarks/operations/http-request.js b/benchmarks/operations/http-request.js index c8b51d248..500a8756d 100644 --- a/benchmarks/operations/http-request.js +++ b/benchmarks/operations/http-request.js @@ -3,13 +3,8 @@ const http = require("http"); module.exports = { step: async function step() { return new Promise((resolve, reject) => { - const options = { - hostname: "localhost", - port: 10411, - }; - - const req = http.request(options, (res) => { - res.on("data", () => {}); + const req = http.request("http://localhost:10411", (res) => { + res.resume(); res.on("end", resolve); }); diff --git a/benchmarks/operations/package-lock.json b/benchmarks/operations/package-lock.json index 4594d6f90..2722b4f51 100644 --- a/benchmarks/operations/package-lock.json +++ b/benchmarks/operations/package-lock.json @@ -10,7 +10,8 @@ "dependencies": { "@aikidosec/firewall": "file:../../build", "better-sqlite3": "^11.7.2", - "mongodb": "^6.9.0" + "mongodb": "^6.9.0", + "undici": "^7.3.0" } }, "../../build": { @@ -540,6 +541,14 @@ "node": "*" } }, + "node_modules/undici": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.3.0.tgz", + "integrity": "sha512-Qy96NND4Dou5jKoSJ2gm8ax8AJM/Ey9o9mz7KN1bb9GP+G0l20Zw8afxTnY2f4b7hmhn/z8aC2kfArVQlAhFBw==", + "engines": { + "node": ">=20.18.1" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/benchmarks/operations/package.json b/benchmarks/operations/package.json index 20956f93d..736b97aad 100644 --- a/benchmarks/operations/package.json +++ b/benchmarks/operations/package.json @@ -7,6 +7,7 @@ "dependencies": { "@aikidosec/firewall": "file:../../build", "better-sqlite3": "^11.7.2", - "mongodb": "^6.9.0" + "mongodb": "^6.9.0", + "undici": "^7.3.0" } } diff --git a/benchmarks/operations/undici.js b/benchmarks/operations/undici.js new file mode 100644 index 000000000..bda22d2a0 --- /dev/null +++ b/benchmarks/operations/undici.js @@ -0,0 +1,7 @@ +const undici = require("undici"); + +module.exports = { + step: async function step() { + return await undici.request("http://localhost:10411"); + }, +};