Skip to content

lib: reuse invalid state errors on webstreams

We are tracking internally the webstreams performance and after some investigation (https://github.com/nodejs/undici/issues/1203, https://github.com/nodejs/performance/issues/9#issuecomment-1370136019), we found that one of the bottlenecks is the NodeError creation.

  • I'm using undici.fetch as a real use case of web streams, the benchmark files are available at https://github.com/RafaelGSS/nodejs-webstreams-perf/blob/main/bench/fetch.js
  • This patch improves the undici.fetch performance by approximately 23%.
    • Important: I'm considering only the benchmark above.
  • I did all the tests on my developer machine and on a dedicated server, and the results seem consistent.

I'm not quite sure about the security impacts of this change, considering we're going to use the same object for all release calls.

More information on this performance work can be found at https://github.com/nodejs/performance/issues/9.

Merge request reports

Loading