Node.js and Socket.io UTF8 Verification TypeError coming from ws

Getting this error while checking data received from the client through socket.io.

C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:532
6:23:55 PM web.1 |              if (!Validation.isValidUTF8(messageBuffer)) {
6:23:55 PM web.1 |                             ^
6:23:55 PM web.1 |  TypeError: Cannot read property 'isValidUTF8' of undefined
6:23:55 PM web.1 |      at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:532:28
6:23:55 PM web.1 |      at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:368:7
6:23:55 PM web.1 |      at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\PerMessageDeflate.js:249:5
6:23:55 PM web.1 |      at afterWrite (_stream_writable.js:355:3)
6:23:55 PM web.1 |      at onwrite (_stream_writable.js:346:7)
6:23:55 PM web.1 |      at WritableState.onwrite (_stream_writable.js:89:5)
6:23:55 PM web.1 |      at afterTransform (_stream_transform.js:79:3)
6:23:55 PM web.1 |      at TransformState.afterTransform (_stream_transform.js:54:12)
6:23:55 PM web.1 |      at Zlib.callback (zlib.js:613:5)
[DONE] Killing all processes with signal  null
6:23:55 PM web.1 Exited with exit code 1

Editing this section of code in Receiver.js,

if (!Validation.isValidUTF8(messageBuffer)) {
  self.error('invalid utf8 sequence', 1007);
  return;
}

stops the error that occurred, but I would prefer a better solution, since I would like to use NPM, and can not be bothered by the repetition of this with every update.

I also tried installing utf-8-validate in the node_modules socket.io folder without success

+4
source share
1 answer

UPDATE: upgrade wsv2.x can fix it!

modify Receiver.js in the module wsas follows:

var isValidUTF8 = require('./Validation')
...
if (!isValidUTF8(messageBuffer)) {
  ...
}

, , , , Validation, PR ws .

0

Source: https://habr.com/ru/post/1670983/


All Articles