Skip to content

Commit

Permalink
chore: 🤖 add console logs for node bug report
Browse files Browse the repository at this point in the history
Headers are not being passed by websocket in node 22 only and causing
cookie authentication to fail
  • Loading branch information
Danilo Alonso authored and Danilo Alonso committed Jun 26, 2024
1 parent 4d74d39 commit 7cb2e13
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,14 @@
return Promise.reject(err);
}

console.log('send...', encoded);


// Ignore errors

if (!track) {
try {

this._ws.send(encoded);
return Promise.resolve();
}
Expand Down Expand Up @@ -657,6 +661,8 @@
return this.onError(new NesError(err, errorTypes.PROTOCOL));
}

console.log('update...', update);

// Recreate error

let error = null;
Expand Down
2 changes: 2 additions & 0 deletions lib/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ exports = module.exports = internals.Listener = function (server, settings) {
return ws.close();
}

console.log('ws on connection....', req.headers);

this._add(ws, req);
});

Expand Down
5 changes: 5 additions & 0 deletions lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ internals.Socket.prototype._error = function (err, request) {

internals.Socket.prototype._onMessage = async function (message) {

if (Buffer.isBuffer(message)) {

message = message.toString();
}

try {
var request = JSON.parse(message);
}
Expand Down
2 changes: 1 addition & 1 deletion test/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('authentication', () => {
await connecting;
});

describe('cookie', () => {
describe.only('cookie', () => {

it('protects an endpoint', async () => {

Expand Down

0 comments on commit 7cb2e13

Please sign in to comment.