Comments (4)
I wasn't able to reproduce this, do you have a snippet that demonstrates the above?
If you run consul with -log-level=debug
you can see the series of requests, which might help explain what's happening.
What version of the consul agent and node client are you using?
from node-consul.
No other code that the one I've pasted in PR is needed. You just need to start consul with empty KV and apply every step I've described. I've updated first comment with consul logs.
node: v0.12.0
consul agent: Consul v0.4.1
from node-consul.
Interesting, this looks to be Consul Agent version specific. It seems to work fine on 0.5.1
, but not 0.4.1
. I'm not actually sure if this is something I'm going to be able to fix in the client.
Can you just update to the latest Consul Agent?
Consul 0.5.1
20 May 08:48:15 - Step 1
20 May 08:48:15 - test1: undefined
20 May 08:48:15 - test2: undefined
20 May 08:48:16 - Step 2
20 May 08:48:16 - test1: { CreateIndex: 118,
ModifyIndex: 118,
LockIndex: 0,
Key: 'test1',
Flags: 0,
Value: 'test1_value1' }
20 May 08:48:17 - Step 3
20 May 08:48:17 - test2: { CreateIndex: 119,
ModifyIndex: 119,
LockIndex: 0,
Key: 'test2',
Flags: 0,
Value: 'test2_value1' }
20 May 08:48:18 - Step 4
20 May 08:48:18 - test1: { CreateIndex: 118,
ModifyIndex: 120,
LockIndex: 0,
Key: 'test1',
Flags: 0,
Value: 'test1_value2' }
20 May 08:48:19 - Step 5
20 May 08:48:19 - test2: undefined
20 May 08:48:20 - Step 6
20 May 08:48:20 - test1: { CreateIndex: 118,
ModifyIndex: 122,
LockIndex: 0,
Key: 'test1',
Flags: 0,
Value: 'test1_value3' }
Consul 0.4.1
20 May 08:58:14 - Step 1
20 May 08:58:14 - test1: undefined
20 May 08:58:14 - test2: undefined
20 May 08:58:15 - Step 2
20 May 08:58:15 - test1: { CreateIndex: 11,
ModifyIndex: 11,
LockIndex: 0,
Key: 'test1',
Flags: 0,
Value: 'test1_value1' }
20 May 08:58:15 - test2: undefined
20 May 08:58:16 - Step 3
20 May 08:58:16 - test2: { CreateIndex: 12,
ModifyIndex: 12,
LockIndex: 0,
Key: 'test2',
Flags: 0,
Value: 'test2_value1' }
20 May 08:58:17 - Step 4
20 May 08:58:17 - test1: { CreateIndex: 11,
ModifyIndex: 13,
LockIndex: 0,
Key: 'test1',
Flags: 0,
Value: 'test1_value2' }
20 May 08:58:18 - Step 5
20 May 08:58:19 - test2: undefined
20 May 08:58:20 - Step 6
20 May 08:58:20 - test1: { CreateIndex: 11,
ModifyIndex: 15,
LockIndex: 0,
Key: 'test1',
Flags: 0,
Value: 'test1_value3' }
20 May 08:58:20 - test2: undefined
test.js
'use strict';
var async = require('async');
var consul = require('consul')();
var util = require('util');
var watch1;
var watch2;
function watch(key) {
var opts = { method: consul.kv.get, options: { key: key }};
var w = consul.watch(opts);
w.on('change', function (result) {
util.log(key + ':', result);
});
return w;
}
var steps = [];
steps.push(function(next) {
util.log('Step 1');
watch1 = watch('test1');
watch2 = watch('test2');
setTimeout(function() { next(); }, 1000);
});
steps.push(function(next) {
util.log('Step 2');
consul.kv.set('test1', 'test1_value1', function(err) {
if (err) throw err;
setTimeout(function() { next(); }, 1000);
});
});
steps.push(function(next) {
util.log('Step 3');
consul.kv.set('test2', 'test2_value1', function(err) {
if (err) throw err;
setTimeout(function() { next(); }, 1000);
});
});
steps.push(function(next) {
util.log('Step 4');
consul.kv.set('test1', 'test1_value2', function(err) {
if (err) throw err;
setTimeout(function() { next(); }, 1000);
});
});
steps.push(function(next) {
util.log('Step 5');
consul.kv.del('test2', function(err) {
if (err) throw err;
setTimeout(function() { next(); }, 1000);
});
});
steps.push(function(next) {
util.log('Step 6');
consul.kv.set('test1', 'test1_value3', function(err) {
if (err) throw err;
setTimeout(function() { next(); }, 1000);
});
});
async.series(steps, function(err) {
if (err) throw err;
watch1.end();
watch2.end();
});
from node-consul.
You're right, it's consul 0.4 issue. Thats for your time :)
from node-consul.
Related Issues (20)
- access to keys response HOT 3
- TypeError: consul_1.default is not a constructor HOT 1
- TypeScript Support for consul.query HOT 1
- There is no accessible history.md or changelog.md file HOT 1
- Consul queries providing `tag` are deprecated HOT 2
- Long Polling index should be verified > 0 after initial response
- Reset index of watch job if index ever decreases HOT 1
- Can't invoke "new Consul()" HOT 1
- Can't invoke "new Consul()" constructor in typescript app HOT 1
- Release docs? HOT 4
- Typescript support for client.watch HOT 1
- Typescript suppor for grpc healthcheck's HOT 1
- Add Typescript support HOT 2
- Grype scanner found all this vulnerabilities in the library CVE-2018-25046, CVE-2020-13250, CVE-2021-38698, CVE-2022-40716, CVE-2020-7219, CVE-2020-28053, CVE-2021-3121, CVE-2021-37219 HOT 1
- support for kv.List HOT 2
- extend host:port to support multiple agents HOT 4
- Don't set x-consul-token if it's undefined
- how to watch service? HOT 1
- Grpc Check register request ignores `tls_skip_verify` HOT 4
- Question about the usage of "end" function in watch.js HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-consul.