diff --git a/CHANGELOG.md b/CHANGELOG.md index f88112a5..8bd4d016 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,21 @@ Changelog ========= +Version 1.0.31 +-------------- +*Released 2019-12-06* + +* Fix [infinite loop in error handling](https://github.com/theturtle32/WebSocket-Node/issues/329) (Thanks, [@apirila](https://github.com/apirila)) +* Fix [memory leak with multiple WebSocket servers on the same HTTP server](https://github.com/theturtle32/WebSocket-Node/pull/339) (Thanks, [@nazar-pc](https://github.com/nazar-pc)) +* [Use es5-ext/global as a more robust way to resolve browser's window object](https://github.com/theturtle32/WebSocket-Node/pull/362) (Thanks, [@michaelsbradleyjr](https://github.com/michaelsbradleyjr)) +* [adding compatibility with V8 release greater than v7.6 (node and electron engines)](https://github.com/theturtle32/WebSocket-Node/pull/376) (Thanks, [@artynet](https://github.com/artynet)) + +Version 1.0.30 +-------------- +*Released 2019-09-12* + +* Moved gulp back to devDependencies + Version 1.0.29 -------------- *Released 2019-07-03* diff --git a/README.md b/README.md index d881f0d2..c57aa50a 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,6 @@ WebSocket Client & Server Implementation for Node [![NPM Downloads](https://img.shields.io/npm/dm/websocket.svg)](https://www.npmjs.com/package/websocket) -[![NPM](https://nodei.co/npm/websocket.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/websocket/) - -[![NPM](https://nodei.co/npm-dl/websocket.png?height=3)](https://nodei.co/npm/websocket/) - [ ![Codeship Status for theturtle32/WebSocket-Node](https://codeship.com/projects/70458270-8ee7-0132-7756-0a0cf4fe8e66/status?branch=master)](https://codeship.com/projects/61106) Overview @@ -27,9 +23,12 @@ Documentation Changelog --------- -***Current Version: 1.0.29*** — Released 2019-07-03 +***Current Version: 1.0.31*** — Released 2019-12-06 -* Updated some dependencies and updated the .gitignore and .npmignore files +* Fix [infinite loop in error handling](https://github.com/theturtle32/WebSocket-Node/issues/329) (Thanks, [@apirila](https://github.com/apirila)) +* Fix [memory leak with multiple WebSocket servers on the same HTTP server](https://github.com/theturtle32/WebSocket-Node/pull/339) (Thanks, [@nazar-pc](https://github.com/nazar-pc)) +* [Use es5-ext/global as a more robust way to resolve browser's window object](https://github.com/theturtle32/WebSocket-Node/pull/362) (Thanks, [@michaelsbradleyjr](https://github.com/michaelsbradleyjr)) +* [Adding compatibility with V8 release greater than v7.6 (node and electron engines)](https://github.com/theturtle32/WebSocket-Node/pull/376) (Thanks, [@artynet](https://github.com/artynet)) [View the full changelog](CHANGELOG.md) diff --git a/lib/WebSocketConnection.js b/lib/WebSocketConnection.js index 9f2750cc..c14a24ea 100644 --- a/lib/WebSocketConnection.js +++ b/lib/WebSocketConnection.js @@ -348,7 +348,7 @@ WebSocketConnection.prototype.handleSocketError = function(error) { if (utils.eventEmitterListenerCount(this, 'error') > 0) { this.emit('error', error); } - this.socket.destroy(error); + this.socket.destroy(); this._debug.printOutput(); }; diff --git a/lib/WebSocketServer.js b/lib/WebSocketServer.js index c27d967b..f81a8945 100644 --- a/lib/WebSocketServer.js +++ b/lib/WebSocketServer.js @@ -190,6 +190,7 @@ WebSocketServer.prototype.shutDown = function() { }; WebSocketServer.prototype.handleUpgrade = function(request, socket) { + var self = this; var wsRequest = new WebSocketRequest(socket, request, this.config); try { wsRequest.readHandshake(); @@ -208,6 +209,9 @@ WebSocketServer.prototype.handleUpgrade = function(request, socket) { wsRequest.once('requestAccepted', this._handlers.requestAccepted); wsRequest.once('requestResolved', this._handlers.requestResolved); + socket.once('close', function () { + self._handlers.requestResolved(wsRequest); + }); if (!this.config.autoAcceptConnections && utils.eventEmitterListenerCount(this, 'request') > 0) { this.emit('request', wsRequest); diff --git a/package.json b/package.json index 4cbff181..130cbf62 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "contributors": [ "Iñaki Baz Castillo (http://dev.sipdoc.net)" ], - "version": "1.0.29", + "version": "1.0.31", "repository": { "type": "git", "url": "https://github.com/theturtle32/WebSocket-Node.git" diff --git a/src/bufferutil.cc b/src/bufferutil.cc index a53c246d..888ac576 100644 --- a/src/bufferutil.cc +++ b/src/bufferutil.cc @@ -31,7 +31,7 @@ class BufferUtil : public ObjectWrap Nan::SetMethod(t, "unmask", BufferUtil::Unmask); Nan::SetMethod(t, "mask", BufferUtil::Mask); Nan::SetMethod(t, "merge", BufferUtil::Merge); - Nan::Set(target, Nan::New("BufferUtil").ToLocalChecked(), t->GetFunction()); + Nan::Set(target, Nan::New("BufferUtil").ToLocalChecked(), Nan::GetFunction(t).ToLocalChecked()); } protected: @@ -47,14 +47,14 @@ class BufferUtil : public ObjectWrap static NAN_METHOD(Merge) { Nan::HandleScope scope; - Local bufferObj = info[0]->ToObject(); + Local bufferObj = Nan::To(info[0]).ToLocalChecked(); char* buffer = Buffer::Data(bufferObj); Local array = Local::Cast(info[1]); unsigned int arrayLength = array->Length(); size_t offset = 0; unsigned int i; for (i = 0; i < arrayLength; ++i) { - Local src = array->Get(i)->ToObject(); + Local src = Nan::To(Nan::Get(array, Nan::New(i)).ToLocalChecked()).ToLocalChecked(); size_t length = Buffer::Length(src); memcpy(buffer + offset, Buffer::Data(src), length); offset += length; @@ -65,9 +65,9 @@ class BufferUtil : public ObjectWrap static NAN_METHOD(Unmask) { Nan::HandleScope scope; - Local buffer_obj = info[0]->ToObject(); + Local buffer_obj = Nan::To(info[0]).ToLocalChecked(); size_t length = Buffer::Length(buffer_obj); - Local mask_obj = info[1]->ToObject(); + Local mask_obj = Nan::To(info[1]).ToLocalChecked(); unsigned int *mask = (unsigned int*)Buffer::Data(mask_obj); unsigned int* from = (unsigned int*)Buffer::Data(buffer_obj); size_t len32 = length / 4; @@ -86,12 +86,12 @@ class BufferUtil : public ObjectWrap static NAN_METHOD(Mask) { Nan::HandleScope scope; - Local buffer_obj = info[0]->ToObject(); - Local mask_obj = info[1]->ToObject(); + Local buffer_obj = Nan::To(info[0]).ToLocalChecked(); + Local mask_obj = Nan::To(info[1]).ToLocalChecked(); unsigned int *mask = (unsigned int*)Buffer::Data(mask_obj); - Local output_obj = info[2]->ToObject(); - unsigned int dataOffset = info[3]->Int32Value(); - unsigned int length = info[4]->Int32Value(); + Local output_obj = Nan::To(info[2]).ToLocalChecked(); + unsigned int dataOffset = Nan::To(info[3]).ToLocalChecked()->Value(); + unsigned int length = Nan::To(info[4]).ToLocalChecked()->Value(); unsigned int* to = (unsigned int*)(Buffer::Data(output_obj) + dataOffset); unsigned int* from = (unsigned int*)Buffer::Data(buffer_obj); unsigned int len32 = length / 4; diff --git a/src/validation.cc b/src/validation.cc index 3db4f65f..be13c2e1 100644 --- a/src/validation.cc +++ b/src/validation.cc @@ -111,7 +111,7 @@ class Validation : public ObjectWrap Local t = Nan::New(New); t->InstanceTemplate()->SetInternalFieldCount(1); Nan::SetMethod(t, "isValidUTF8", Validation::IsValidUTF8); - Nan::Set(target, Nan::New("Validation").ToLocalChecked(), t->GetFunction()); + Nan::Set(target, Nan::New("Validation").ToLocalChecked(), Nan::GetFunction(t).ToLocalChecked()); } protected: @@ -130,7 +130,7 @@ class Validation : public ObjectWrap if (!Buffer::HasInstance(info[0])) { return Nan::ThrowTypeError("First argument needs to be a buffer"); } - Local buffer_obj = info[0]->ToObject(); + Local buffer_obj = Nan::To(info[0]).ToLocalChecked(); char *buffer_data = Buffer::Data(buffer_obj); size_t buffer_length = Buffer::Length(buffer_obj); info.GetReturnValue().Set(is_valid_utf8(buffer_length, buffer_data) == 1 ? Nan::True() : Nan::False());