Repository navigation
Report the real package version in the user agent (hscn/<version>) and release 1.5.1 - #65
Merged
Merged
Conversation
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@build.rs`:
- Around line 12-25: The current manual line-based parsing in build.rs that
computes the local variable version is brittle; instead add serde_json = "1.0"
to [build-dependencies] in Cargo.toml and replace the manual
read/line/strip_prefix logic with a robust JSON parse using serde_json::from_str
to extract the "version" field (falling back to
env!("CARGO_PKG_VERSION").to_string() if parsing or key extraction fails).
Locate the code that defines version in build.rs (and the use of
env!("CARGO_PKG_VERSION")) and update it to read package.json, parse it with
serde_json::Value (or a small struct with a version field), and use that value
as the version.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1592ab44-7012-4a2c-8e38-443fa2e13429
📒 Files selected for processing (2)
build.rssrc/lib.rs
The user agent was hscn/{CARGO_PKG_VERSION}, but napi keeps the Cargo package
version at 0.0.0, so it always sent hscn/0.0.0. build.rs now reads the version
from package.json and injects it as NPM_PKG_VERSION, and the client uses that
(hscn/<package-version>).
build.rs reads package.json directly rather than relying on a build-env var, so
the published artifacts get the correct version: the publish workflow builds each
target with 'yarn build' from a checkout whose package.json holds the release
version. Falls back to CARGO_PKG_VERSION if package.json can't be read.
…is missing Addresses review feedback: line-based parsing was brittle, and falling back to CARGO_PKG_VERSION would silently reintroduce hscn/0.0.0. Resolve package.json via CARGO_MANIFEST_DIR and emit rerun-if-changed before reading it (required because napi_build's rerun-if-env-changed directives disable cargo's default rerun).
JonoPrest
force-pushed
the
set-user-agent
branch
from
October 30, 2026 08:23
2b490c5 to
a097585
Compare
Bump package.json, the npm/* platform packages and the version embedded in index.js, so the release reports hscn/1.5.1.
JonoPrest
added a commit
that referenced
this pull request
Oct 30, 2026
* Fix cargo fmt in src/lib.rs * Add CI workflow for pull requests and main Runs on every PR and push to main (there was no PR CI before; the only build and tests ran inside the manual publish workflow): - cargo fmt, clippy (-D warnings) and cargo test - yarn build, then fail if the committed index.js / index.d.ts differ from what napi generates - yarn test on node 20, 22 and 24 - a packaging smoke test that packs the main and platform packages as they are published, installs them into a fresh project and checks require, import and a TypeScript type-check against index.d.ts * Add offline regression tests for past fixes A loopback fake HyperSync server captures what the client sends, so query conversion, headers and rate limiting can be tested without network access or an API token. Covers: - include/exclude selections not collapsing to empty filters (#52) - transaction/trace 'type' field names (#22, #27, #43) and runtime enums (#30) - authorization list filters (#37) and query validation errors - hscn/<package version> user agent and bearer token (#44, #65) - rate limit parsing and proactive sleep (#57) - setLogLevel and RUST_LOG precedence (#62), in child processes - index.js/index.d.ts export parity (#63) and version consistency (#47) - decoder address independence (#10), checksumming (#18) and bad input - preset queries - Rust: response address checksumming (#18) and BigInt quantities (#20, #23) * Type-check examples in CI and run them against HyperSync scripts/check-examples.sh installs each example against the local build and type-checks it. With --run it also runs each one with ENVIO_API_TOKEN: examples that finish must exit 0 within RUN_SECONDS, streaming ones must still be running cleanly at that point, and any ERROR logged by the client fails the example (the client retries failed requests forever, so a bad token or broken query would otherwise just look like a slow example). The run job skips with a warning when the ENVIO_API_TOKEN secret isn't available, e.g. on fork PRs. * Widen rate limit window in proactive sleep test Addresses review feedback: with a 1s reset window, a CI pause between the two calls could let the window expire and fail the test spuriously. * Run examples in parallel and stop streaming ones once data arrives Streaming examples now pass as soon as they print their first real output instead of running for a fixed 60s, every example runs concurrently, and anything still running at RUN_TIMEOUT is reported as hung. Errors printed by the examples themselves (e.g. height-stream catches its own) now also fail. * Fix CallDecoder decoding and crashes on short input Caught by the call_watch example once it ran in CI: - hypersync_client::CallDecoder passes the calldata to abi_decode_input with its 4-byte selector still attached, so every argument came out shifted (addresses like 0x00000000c782..., huge amounts). - It indexes data[0..4] without a length check, so a transaction with empty input (a plain ETH transfer) panicked; the binding's .unwrap() on the spawn_blocking JoinError then aborted the whole Node process. The binding now keeps its own selector -> Function map and decodes with alloy directly, stripping the selector. Input that isn't valid hex, is too short, has an unknown selector or doesn't decode returns null, matching how Decoder treats undecodable logs. The async variants reject instead of aborting if the decode task ever panics. The existing checksum toggles are now exported to JS, as they were meant to be. * Address review findings on CI scripts - check-examples: record each result in its own file instead of parsing the last log line (truncated output was glued onto the result, failing call_watch even though it passed); show the tail of the output, where failures are; run examples from scratch directories so parquet-out's data/ isn't left in the checkout; keep ENVIO_API_TOKEN out of npm install / tsc; require call_watch to print a real decoded transfer. - ci.yaml: only expose ENVIO_API_TOKEN to the step that runs the examples. - smoke-test-package: the stray .node guard used '! ls', which set -e ignores, so it could never fail. Also add the optionalDependencies napi adds at publish time (using napi's own parseTriple) and install only the main package, so the platform binary has to resolve the way it does for users. - package.test: each napi target has a matching npm/<platform> package.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The client already tags requests with
hscn/<version>, but the version came fromCARGO_PKG_VERSION— and napi keeps the Cargo package version pinned at0.0.0, so every request actually went out ashscn/0.0.0.This makes
build.rsread the version frompackage.jsonand inject it asNPM_PKG_VERSION, which the client now uses →hscn/<package-version>(e.g.hscn/1.5.1).Release
Bumps to 1.5.1 (
package.json,npm/*platform packages, and the version embedded inindex.js), mirroring the 1.5.0 release in #67.Why the release gets the right version
build.rsreadspackage.jsondirectly, not via any build-time env var the pipeline may or may not set. The publish workflow (publish_to_npm.yaml) builds each platform withcheckout→yarn install→yarn build, so the artifact is compiled from a checkout whosepackage.jsonholds the release version (kept in sync bynapi version).package.jsonis parsed withserde_json(resolved viaCARGO_MANIFEST_DIR), and there is deliberately no fallback: a missing or malformed version fails the build rather than silently shippinghscn/0.0.0.Matches the Rust (
hscr/) and Python (hscp/, separate PR) clients. Verified withcargo check(theenv!("NPM_PKG_VERSION")would fail to compile if build.rs didn't set it; the version parses to 1.5.1; removing the field fails the build with a clear error).Summary by CodeRabbit