question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Permissions Violation during subscribe unexpectedly closes the whole connection

See original GitHub issue
  • Client version: 2.8.0
  • Node version: 16.14.2

What’s happening

If in subscription iterator for await (const message of subscription) happens Permissions Violation error like this

NatsError: 'Permissions Violation for Subscription to "subject"'
    at Function.toError (/code/node_modules/nats/lib/nats-base-client/protocol.js:306:20)
    at ProtocolHandler.<anonymous> (/code/node_modules/nats/lib/nats-base-client/protocol.js:339:41)
    at Generator.next (<anonymous>)
    at /code/node_modules/nats/lib/nats-base-client/protocol.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/code/node_modules/nats/lib/nats-base-client/protocol.js:4:12)
    at ProtocolHandler.processError (/code/node_modules/nats/lib/nats-base-client/protocol.js:337:16)
    at ProtocolHandler.push (/code/node_modules/nats/lib/nats-base-client/protocol.js:426:22)
    at Parser.parse (/code/node_modules/nats/lib/nats-base-client/parser.js:312:45)
    at ProtocolHandler.<anonymous> (/code/node_modules/nats/lib/nats-base-client/protocol.js:189:45)

it will close the whole NATS connection. Here’s what connection.closed() will yield (same error):

NatsError: 'Permissions Violation for Subscription to "subject"'
    at Function.toError (/code/node_modules/nats/lib/nats-base-client/protocol.js:306:20)
    at ProtocolHandler.<anonymous> (/code/node_modules/nats/lib/nats-base-client/protocol.js:339:41)
    at Generator.next (<anonymous>)
    at /code/node_modules/nats/lib/nats-base-client/protocol.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/code/node_modules/nats/lib/nats-base-client/protocol.js:4:12)
    at ProtocolHandler.processError (/code/node_modules/nats/lib/nats-base-client/protocol.js:337:16)
    at ProtocolHandler.push (/code/node_modules/nats/lib/nats-base-client/protocol.js:426:22)
    at Parser.parse (/code/node_modules/nats/lib/nats-base-client/parser.js:312:45)
    at ProtocolHandler.<anonymous> (/code/node_modules/nats/lib/nats-base-client/protocol.js:189:45)

What’s expected

I think closing the whole connection is very unexpected behavior here. While clearly, this is usually a human error when setting up NATS permissions, the fact that some subscriptions failed to doesn’t mean that the whole connection should be killed because other subs are still able to work. It should be up to the application to decide what to do in such situations.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:22 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
ArmorDarkscommented, Dec 1, 2022

Yeap, the issue is present only in v2.8.0.

With 2.8.1-2 I’m unable to reproduce it, so we’re good to go 👍

1reaction
aricartcommented, Dec 1, 2022

It might be, but it’s always closing after an attempt to subscribe to the subject without permission. It’s 100% reproducible.

Sorry, I’ve put the wrong version number. We’re using 2.8.1-2 which was introduced for nats-io/nats.js#524

Going to put the same test in node, perhaps something is not quite right there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected error when performing consent to an application
This error can occur when a Global Administrator turns off the ability for users to consent to applications, then a non-administrator user ...
Read more >
Ads - Play Console Help - Google Support
Disruptive ads are ads that are displayed to users in unexpected ways, that may result in inadvertent clicks, or impairing or interfering with...
Read more >
Troubleshooting Cloud Functions - Google Cloud
... Deployment service account missing Pub/Sub permissions when deploying an ... service must access Cloud Pub/Sub to configure topics and subscriptions.
Read more >
A Banking App Has Been Suddenly Closing Accounts ...
Chime, a “neobank” serving millions, is racking up complaints from users who can't access their cash. The company says it's cracking down on ......
Read more >
chrome.webRequest - Chrome Developers
You must declare the "webRequest" permission in the extension manifest to use the web request API, along with the necessary host permissions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found