From 5aed381963a7a013b4ecc9fa02cc0b26cc6f6dba Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 8 Jul 2018 02:50:03 +0000 Subject: [PATCH] excessively log pairing states --- lib/extensions/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/extensions/index.js b/lib/extensions/index.js index 41a45dc..1e7562c 100644 --- a/lib/extensions/index.js +++ b/lib/extensions/index.js @@ -405,30 +405,37 @@ app.get(urls.pairState, function (req, res) { // or respond after time if it does not complete var auth = Auths.get(req.params.id); // id or secret accepted if (!auth) { + console.log("[pair_state] invalid (bad state id)", req.params.id); res.send({ status: 'invalid' }); return; } function check(i) { + console.log("[pair_state] check i =", i, req.params.id); if (auth._claimed) { + console.log("[pair_state] complete", req.params.id); res.send({ status: 'complete' }); } else if (auth._offered) { + console.log("[pair_state] ready", req.params.id); res.send({ status: 'ready', access_token: auth.authz , grant: { domains: auth.domains || [], ports: auth.ports || [] } }); } else if (false === auth._offered) { + console.log("[pair_state] failed", req.params.id); res.send({ status: 'failed', error: { message: "device pairing failed" } }); - } else if (i >= 5) { + } else if (i >= 7) { + console.log("[pair_state] overdue i =", i, req.params.id); var stateUrl = 'https://' + req._state.config.apiDomain + urls.pairState.replace(/:id/g, auth.id); res.statusCode = 200; res.setHeader('Location', stateUrl); res.setHeader('Link', '<' + stateUrl + '>;rel="next"'); res.send({ status: 'pending' }); } else { - setTimeout(check, 3 * 1000, i + 1); + console.log("[pair_state] try again i =", i, req.params.id); + setTimeout(check, 250, i + 1); } } check(0);