perf(capabilities): reduce http request overhead#127
perf(capabilities): reduce http request overhead#127paullegranddc wants to merge 2 commits intobengl/native-spansfrom
Conversation
This is done in multiple ways:
* Do not copy the request body or headers. These are passed to JS as
pointers into the WASM memory. If they become detached during the
request, it is retried
* Allow separating the request from the async local storage
in order to no instrument it
* Enabled agent rates header, reducing agent response size if unchanged
* More efficient response header parsing, reducing copies
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ece00f03a0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| resolve([ | ||
| res.statusCode, | ||
| res.rawHeaders, | ||
| new Uint8Array(body.buffer), |
There was a problem hiding this comment.
Preserve Buffer bounds when returning response body
Buffer.concat(chunks) can return a pooled Buffer whose byteOffset/byteLength cover only part of its underlying ArrayBuffer; constructing new Uint8Array(body.buffer) exposes the entire backing store instead of just the response bytes. In those cases the Rust side receives extra stale bytes (and potentially unrelated memory), corrupting HTTP response payloads for small responses. Return a view that respects the buffer slice (e.g., with offset/length) before passing it across WASM.
Useful? React with 👍 / 👎.
| HeaderName::from_bytes(key.as_bytes()).unwrap(), | ||
| HeaderValue::from_maybe_shared(Bytes::from(val)).unwrap(), |
There was a problem hiding this comment.
Replace header parsing unwraps with fallible handling
Response header parsing now calls unwrap() on both HeaderName::from_bytes(...) and HeaderValue::from_maybe_shared(...); any non-conformant upstream header (invalid token/value bytes) will panic this request path instead of returning an HttpError. This is a regression from the previous non-panicking behavior and can crash or trap the WASM execution when talking to unexpected or malformed HTTP servers.
Useful? React with 👍 / 👎.
This is done in multiple ways:
pointers into the WASM memory. If they become detached during the
request, it is retried
in order to no instrument it