ravendb/ravendb-nodejs-client

Error "Max topology update tries reached" with trailing slash in url

Closed this issue · 3 comments

This is not so much a bug, but improper usage by the consumer which might be resolved by informing the user.

In short, when adding a slash to the urlOrUrls property during connect, I'm getting the following error:

[04/21/2018 13:02:45] System.Private.CoreLib: Exception while executing function: Functions.event-grid-listener. System.Private.CoreLib: Result:
[04/21/2018 13:02:45] Exception: ue: Max topology update tries reached
[04/21/2018 13:02:45] Stack: ue: Max topology update tries reached
[04/21/2018 13:02:45]     at _withoutTopology._awaitFirstTopologyLock.acquire.then.e (/Users/.../node_modules/ravendb/lib/ravendb-node.js:2:55187)
[04/21/2018 13:02:45]     at tryCatcher (/Users/.../node_modules/bluebird/js/release/util.js:16:23)
[04/21/2018 13:02:45]     at Promise._settlePromiseFromHandler (/Users/.../node_modules/bluebird/js/release/promise.js:512:31)
[04/21/2018 13:02:45]     at Promise._settlePromise (/Users/.../node_modules/bluebird/js/release/promise.js:569:18)
[04/21/2018 13:02:45]     at Promise._settlePromise0 (/Users/.../node_modules/bluebird/js/release/promise.js:614:10)
[04/21/2018 13:02:45]     at Promise._settlePromises (/Users/.../node_modules/bluebird/js/release/promise.js:693:18)
[04/21/2018 13:02:45]     at Async._drainQueue (/Users/.../node_modules/bluebird/js/release/async.js:133:16)
[04/21/2018 13:02:45]     at Async._drainQueues (/Users/.../node_modules/bluebird/js/release/async.js:143:10)
[04/21/2018 13:02:45]     at Immediate.Async.drainQueues (/Users/.../node_modules/bluebird/js/release/async.js:17:14)
[04/21/2018 13:02:45]     at runCallback (timers.js:789:20)
[04/21/2018 13:02:45]     at tryOnImmediate (timers.js:751:5)
[04/21/2018 13:02:45]     at processImmediate [as _immediateCallback] (timers.js:722:5).

Steps to reproduce:

const endpoint = 'http://127.0.0.1:8888/';

const store = DocumentStore.create(endpoint, 'smurfs');
store.initialize();

const session = store.openSession();

const response = await session.query({
        collection: 'Smurfs'
    }).all();

In order to fix it, simply remove the trailing slash from the endpoint:

const endpoint = 'http://127.0.0.1:8888/';

My suggestion would be to add a console.warn() to the UriUtility.parseUrls() function if that's the case. As an alternative solution, the trailing slash could also be removed by the parseUrls() function. However, I can imagine you might consider this to obfuscate that there is a problem.

I'll be happy to submit a PR for either solution, if this would be considered useful?

Yes, that is an issue. Both because of the bad error and for the fact that something this common isn't handled.
We need to trim the / from the string, and we should show the full URL we tried anyway.

@hanssens Thank you for taking time to report that. We'll doing a major sync-up with other clients right now and the fix for this will be handled as part of that changeset. I'll keep you posted.

This is fixed in the latest version.