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.

waitOnFirstConnect and timeout

See original GitHub issue

Hello, I’ve been making some tests and i’m having some issue when using the waitOnFirstConnect together with the timeout option. The script is waiting forever and does not seem to respect the timeout. Here is simple example script

const NATS = require("nats");

async function run() {
    const nc = await NATS.connect({
        servers: 'nats://localhost:4222',
        waitOnFirstConnect: true,
        timeout: 10000,
    });
    console.log('connected');

    nc.closed().finally(() => {
        console.log(`Connection definitely closed`);
    });
}

run();

Expected: finish after 10 seconds when no nats server is running Actual: hangs forever

Am i missing something or do you think there could be a bug somewhere ?

Thank you for your help

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aricartcommented, Aug 11, 2021

That is a bug then. Will fix Monday.

0reactions
tkjwacommented, Aug 12, 2021

@aricart Thank you very much for your time and detailed explanation !

Read more comments on GitHub >

github_iconTop Results From Across the Web

NatsConnectionOptions | ts-nats
A list of server URLs where the client should attempt a connection. Optional timeout. timeout: undefined | number. Defined in ...
Read more >
reconnection error with v2.0.0-213 · Issue #376 · nats-io/nats.js
I'm using version 2.0.0-213 installed by npm install nats@beta . ... After a short period of time nats.js throws an exception: (node:10288) ...
Read more >
Cant use jwt connect nats by my code,its doesnt work
I want to use Nats websocket but I don't know how to get user information so I use jwt and it works but...
Read more >
Authentication Timeout - NATS Docs
Authentication Timeout · If a client doesn't authenticate to the server within the specified time, the server disconnects the server to prevent abuses....
Read more >
nats.ws - UNPKG
355, // by default the request times out after 1s (1000 millis) and has ... 767, | `waitOnFirstConnect` | `false` | If `true`...
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