Skip to content

fix: replace deprecated nats package with @nats-io/transport-node - #9

Merged
sujal-maheshwari2004 merged 1 commit into
mainfrom
fix/5-nats-transport-node
Oct 18, 2026
Merged

sujal-maheshwari2004 merged 1 commit into
mainfrom
fix/5-nats-transport-node

Conversation

@sujal-maheshwari2004

Copy link
Copy Markdown
Contributor

What was wrong

npm i @priompt/client pulled the optional nats@2.29.3, which npm flags as deprecated:

npm warn deprecated nats@2.29.3: Package moved. Use @nats-io/transport-node from https://github.com/nats-io/nats.js

Fix

  • optionalDependencies: nats@^2 → @nats-io/transport-node@^3 (still optional).
  • subscribe() requires @nats-io/transport-node; v3 drops StringCodec, so payloads are read with Msg.string(). Behaviour is otherwise unchanged (JSON event, pre-0.7 bare-hash fallback, token from natsUrl/natsToken).
  • README install note updated.
  • The repo had no test suite: added npm test (node --test) with a small in-process NATS broker (test/fake-nats.js), and CI now runs it.

Test evidence

Regression test, before the fix (main's client.js/package.json):

✖ depends on @nats-io/transport-node, not the deprecated nats package
  AssertionError [ERR_ASSERTION]: the `nats` package is deprecated
✔ subscribe delivers version and classification
ℹ pass 1
ℹ fail 1

After:

$ npm test
✔ depends on @nats-io/transport-node, not the deprecated nats package
✔ subscribe delivers version and classification
ℹ pass 2
ℹ fail 0

Fresh install of the package from this branch (npm i ../js-sdk --install-links): no deprecation warning, tree contains @nats-io/transport-node@3.4.0.

Real run against priompt v0.7.2 serve -nats-token natssecret (subscribe with nats://natssecret@127.0.0.1:48222, then publish over gRPC):

published {"version_hash":"e9d698b91e69d74caa0f29a8c4a067b2b6c352dcdc6a9b8072feca5703f9ac9f"}
event e9d698b91e69 "structural"

Fixes #5

🤖 Generated with Claude Code

nats@2 is deprecated ("Package moved. Use @nats-io/transport-node").
Switch the optional subscribe() dependency to @nats-io/transport-node@3,
which drops StringCodec in favour of Msg.string(). It stays optional.

Add an npm test suite (node:test) with a small in-process NATS broker,
and run it in CI.

Fixes #5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sujal-maheshwari2004
sujal-maheshwari2004 merged commit 3174fba into main Oct 18, 2026
1 check passed
@sujal-maheshwari2004
sujal-maheshwari2004 deleted the fix/5-nats-transport-node branch October 18, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace deprecated nats dependency

1 participant