Commit 00dd21feb644ef3bc4da675b0b9edf96305343b8
detect when flume gets stuck, so I know how often it happens, so I can know how long I need to wait to test it, since I can't reproduce it yet
Dominic Tarr committed on 4/6/2017, 7:06:56 PMParent: b0c67749a854dd5b744d0fd4e950a350d8839dfe
Files changed
.gitignore | changed |
index.js | changed |
index.js | ||
---|---|---|
@@ -60,18 +60,37 @@ | ||
60 | 60 … | } |
61 | 61 … | |
62 | 62 … | function since () { |
63 | 63 … | var plugs = {} |
64 … | + var sync = false | |
64 | 65 … | for(var k in ssb) { |
65 | - if(ssb[k] && isObject(ssb[k]) && isFunction(ssb[k].since)) | |
66 … | + if(ssb[k] && isObject(ssb[k]) && isFunction(ssb[k].since)) { | |
66 | 67 … | plugs[k] = ssb[k].since.value |
68 … | + sync = sync || (plugs[k] === ssb.since.value) | |
69 … | + } | |
67 | 70 … | } |
68 | 71 … | return { |
69 | 72 … | since: ssb.since.value, |
70 | - plugins: plugs | |
73 … | + plugins: plugs, | |
74 … | + sync: sync | |
71 | 75 … | } |
72 | 76 … | } |
73 | 77 … | |
78 … | + var state = since() | |
79 … | + setInterval(function (){ | |
80 … | + var _state = since() | |
81 … | + if(state && !state.sync && !_state.sync && state.since == _state.since) { | |
82 … | + console.log(state, _state) | |
83 … | + //flume is stuck again. | |
84 … | + require('fs').appendFileSync('stuck.log', JSON.stringify({ | |
85 … | + time: new Date(), | |
86 … | + state: state | |
87 … | + }, null, 2) + '\n\n') | |
88 … | + throw new Error('flume is stuck') | |
89 … | + } | |
90 … | + state = _state | |
91 … | + }, 1000).unref() | |
92 … | + | |
74 | 93 … | return { |
75 | 94 … | id : feed.id, |
76 | 95 … | keys : opts.keys, |
77 | 96 … | |
@@ -146,4 +165,12 @@ | ||
146 | 165 … | appKey: require('./lib/ssb-cap') |
147 | 166 … | }) |
148 | 167 … | .use(SSB) |
149 | 168 … | |
169 … | + | |
170 … | + | |
171 … | + | |
172 … | + | |
173 … | + | |
174 … | + | |
175 … | + | |
176 … | + |
Built with git-ssb-web