Skip to content

Commit

Permalink
add some debug logging for cloud testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Garfonso committed Nov 12, 2024
1 parent da10383 commit 94e131f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,7 @@ class WebServer {

// on http://localhost:3000/auth/authorize?response_type=code&client_id=http%3A%2F%2Flocalhost%3A3000%2F&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Flovelace%3Fauth_callback%3D1&state=eyJoYXNzVXJsIjoiaHR0cDovL2xvY2FsaG9zdDozMDAwIiwiY2xpZW50SWQiOiJodHRwOi8vbG9jYWxob3N0OjMwMDAvIn0%3D
this._app.get('/auth/authorize', (req, res) => {
this.log.debug('PRO-debug: auth/authorize - started.');
res.setHeader('location', `/frontend_es5/authorize.html${req.url.replace(/^\//, '').replace(/^auth\/authorize/, '')}`);
res.status(302).send();
});
Expand All @@ -1734,6 +1735,7 @@ class WebServer {

this._app.post('/auth/login_flow', (req, res) => {
console.log(`/auth/login_flow${JSON.stringify(req.query)}${JSON.stringify(req.body)}`);
this.log.debug('PRO-debug: /auth/login_flow');

generateRandomToken((_err, token) => {
this._auth_flows[token] = {ts: Date.now()};
Expand Down Expand Up @@ -2286,6 +2288,7 @@ class WebServer {

ws.on('error', e => {
console.error(`Error: ${e}`);
this.log.debug('PRO-debug: ws error: ' + e + ' - ' + e.stack);
clearInterval(testTimer);
testTimer = null;
});
Expand All @@ -2298,9 +2301,11 @@ class WebServer {

//connection is up, let's add a simple event
ws.on('message', async message => {
this.log.debug('PRO-debug: ws message received');
try {
message = JSON.parse(message);
} catch (e) {
this.log.debug(`Could not parse message: ${message} with type ${typeof message}, got error ${e} with stack ${e.stack}`);
console.error(`Cannot parse message: ${message}`);
return;
}
Expand Down Expand Up @@ -2539,6 +2544,7 @@ class WebServer {

ws.on('close', () => {
this.log.debug('Connection closed');
this.log.debug('PRO-debug: ws close');
ws._subscribes = null;
ws.__templates = null;
clearInterval(testTimer);
Expand Down

0 comments on commit 94e131f

Please sign in to comment.