Skip to content

Commit fb34e63

Browse files
committed
chore(pipeline): address review \u2014 release profile, unused deps/methods, docs
Address szegedi's review on the wasm binding: - Restore the release profile to strip=true and drop debug=true (a debugging leftover; matters for the published package size, and matches main). - Remove the unused @napi-rs/cli runtime dependency \u2014 nothing invokes it and main builds the native prebuilds without it. - Remove the unused StatsCollector::flush and set_agent_url methods (dead since flush was split into prepare_request/send_request); clears the dead_code warning. - Fix the prepareChunk error message (was mislabeled sendPreparedChunk) and the parse_response_headers doc (it takes a flat [name, value, ...] array, not an object). - Document why the WASM_MEMORY LazyLock<JsValue> is Sync (wasm32-only).
1 parent ca379b4 commit fb34e63

5 files changed

Lines changed: 8 additions & 31 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ codegen-units = 1
1313
lto = true
1414
opt-level = "z"
1515
panic = "abort"
16-
# strip = "none"
17-
debug = true
16+
strip = true

crates/capabilities/src/http.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use wasm_bindgen_futures::JsFuture;
1919
use libdd_capabilities::http::{HttpClientCapability, HttpError};
2020
use libdd_capabilities::maybe_send::MaybeSend;
2121

22+
// A `static` requires `Sync`, and `LazyLock<JsValue>: Sync` needs `JsValue:
23+
// Sync` — which holds only because on wasm32 (single-threaded) wasm-bindgen
24+
// implements `Send`/`Sync` for `JsValue`. This crate is wasm32-only, so it's sound.
2225
static WASM_MEMORY: LazyLock<JsValue> = LazyLock::new(wasm_bindgen::memory);
2326

2427
#[wasm_bindgen(module = "/src/http_transport.js")]
@@ -132,9 +135,9 @@ impl HttpClientCapability for WasmHttpClient {
132135
}
133136
}
134137

135-
/// Parse response headers from a JS object `{ "header-name": "value", ... }`.
136-
///
137-
/// Node.js `res.headers` returns lowercased header names with string values.
138+
/// Parse response headers from Node's flat `[name, value, name, value, ...]`
139+
/// array (`res.rawHeaders`): even indices are (lowercased) header names, odd
140+
/// indices their string values.
138141
fn parse_response_headers(header_js: Array<JsString>) -> Result<HeaderMap, HttpError> {
139142
let len = header_js.length() as usize;
140143
let mut headers = HeaderMap::with_capacity(len / 2);

crates/pipeline/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl WasmSpanState {
405405
let mut span_ids = Vec::with_capacity(count as usize);
406406
while count > 0 {
407407
let span_id: u64 = get_num(chunk, &mut index)
408-
.ok_or_else(|| JsValue::from_str("sendPreparedChunk: span id index out of bounds"))?;
408+
.ok_or_else(|| JsValue::from_str("prepareChunk: span id index out of bounds"))?;
409409
span_ids.push(span_id);
410410
count -= 1;
411411
}

crates/pipeline/src/stats.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,6 @@ impl StatsCollector {
123123
.map_err(|e| format!("stats send error: {e:?}"))?;
124124
Ok(())
125125
}
126-
127-
/// Flush aggregated stats and send to the agent.
128-
///
129-
/// Returns `Ok(true)` if stats were sent, `Ok(false)` if there was nothing
130-
/// to send, or `Err` on transport failure. Convenience wrapper around
131-
/// `prepare_request` + `send_request`; callers that flush concurrently with
132-
/// trace export should use those two directly so the collector isn't held
133-
/// across the await (see `flushStats`).
134-
pub async fn flush(&mut self, force: bool) -> Result<bool, String> {
135-
match self.prepare_request(force)? {
136-
Some(req) => {
137-
Self::send_request(req).await?;
138-
Ok(true)
139-
}
140-
None => Ok(false),
141-
}
142-
}
143-
144-
/// Update the agent URL (e.g. after reconfiguration).
145-
pub fn set_agent_url(&mut self, url: String) {
146-
self.agent_url = url;
147-
}
148126
}
149127

150128
/// Encode flushed stats buckets into a `ClientStatsPayload` for msgpack

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
"publishConfig": {
3030
"access": "public"
3131
},
32-
"dependencies": {
33-
"@napi-rs/cli": "^3.6.0"
34-
},
3532
"devDependencies": {
3633
"@eslint/js": "^10.0.1",
3734
"@stylistic/eslint-plugin": "^5.9.0",

0 commit comments

Comments
 (0)