somratpro commited on
Commit
53c803e
·
1 Parent(s): 24ad4e6

debug: snapshot Redis login:/external: 100/500/1500ms after X callback

Browse files
Files changed (1) hide show
  1. health-server.js +21 -0
health-server.js CHANGED
@@ -2205,6 +2205,27 @@ const server = http.createServer((req, res) => {
2205
  try {
2206
  fs.appendFileSync("/tmp/x-oauth-callbacks.log", msg + "\n");
2207
  } catch(_) {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2208
  }
2209
 
2210
  res.writeHead(302, {
 
2205
  try {
2206
  fs.appendFileSync("/tmp/x-oauth-callbacks.log", msg + "\n");
2207
  } catch(_) {}
2208
+
2209
+ // Snapshot Redis 100ms, 500ms, 1500ms after callback to catch login: key before it's deleted
2210
+ if (!denied && oauthToken !== "(missing)") {
2211
+ const snapshots = [];
2212
+ const doSnap = (delay) => setTimeout(() => {
2213
+ try {
2214
+ const { execSync } = require("child_process");
2215
+ const rc = (cmd) => { try { return execSync(cmd, { timeout: 3000 }).toString().trim(); } catch(e) { return "(err)"; } };
2216
+ const loginVal = rc(`redis-cli -h 127.0.0.1 -p 6379 get "login:${oauthToken}" 2>/dev/null`);
2217
+ const extVal = rc(`redis-cli -h 127.0.0.1 -p 6379 get "external:${oauthToken}" 2>/dev/null`);
2218
+ const loginTtl = rc(`redis-cli -h 127.0.0.1 -p 6379 ttl "login:${oauthToken}" 2>/dev/null`);
2219
+ const extTtl = rc(`redis-cli -h 127.0.0.1 -p 6379 ttl "external:${oauthToken}" 2>/dev/null`);
2220
+ const snap = ` [+${delay}ms] login:TOKEN=${loginVal ? loginVal.slice(0,40) + "...(len=" + loginVal.length + ")" : "(empty/missing)"} ttl=${loginTtl} | external:TOKEN=${extVal ? extVal.slice(0,40) + "...(len=" + extVal.length + ")" : "(empty/missing)"} ttl=${extTtl}`;
2221
+ snapshots.push(snap);
2222
+ fs.appendFileSync("/tmp/x-oauth-callbacks.log", snap + "\n");
2223
+ } catch(_) {}
2224
+ }, delay);
2225
+ doSnap(100);
2226
+ doSnap(500);
2227
+ doSnap(1500);
2228
+ }
2229
  }
2230
 
2231
  res.writeHead(302, {