Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4770

node.js 10 compatibilityand/or deprecation fixes

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 0.12.0
    • Fix Version/s: None
    • Component/s: Node.js - Library
    • Labels:
      None

      Description

      Using nvm I tried running a "make check" and found that the style of buffer allocation used (i.e. "new Buffer(...) is deprecated in Node 10.  We need to switch according to the deprecation warning:
      ```
      (node:28258) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
      ```

      Some affected code:
      ```
      root@855cc5f903a0:/thrift/src/lib/nodejs# grep -r 'new Buffer'
      lib/thrift/ws_connection.js: var buf = new Buffer(data);
      lib/thrift/int64_util.js: var buffer = new Buffer(8);
      lib/thrift/web_server.js: var frame = new Buffer(wsFrame.frameSizeFromData(data, mask));
      lib/thrift/web_server.js: result.mask = new Buffer(4);
      lib/thrift/web_server.js: result.data = new Buffer(len);
      lib/thrift/web_server.js: result.nextFrame = new Buffer(frame.length - (dataOffset+len));
      lib/thrift/web_server.js: var newData = new Buffer(data.length + result.data.length);
      lib/thrift/binary_protocol.js: this.trans.write(new Buffer([b]));
      lib/thrift/binary_protocol.js: this.trans.write(binary.writeI16(new Buffer(2), i16));
      lib/thrift/binary_protocol.js: this.trans.write(binary.writeI32(new Buffer(4), i32));
      lib/thrift/binary_protocol.js: this.trans.write(binary.writeDouble(new Buffer(8), dub));
      lib/thrift/binary_protocol.js: this.trans.write(new Buffer(arg, encoding));
      lib/thrift/binary_protocol.js: return new Buffer(0);
      lib/thrift/xhr_connection.js: var thing = new Buffer(data || buf);
      lib/thrift/http_connection.js: data.push(new Buffer(chunk));
      lib/thrift/http_connection.js: var buf = new Buffer(dataLen);
      lib/thrift/json_protocol.js: var buf = new Buffer(arg, 'binary');
      lib/thrift/json_protocol.js: return new Buffer(this.readValue(), 'base64');
      lib/thrift/compact_protocol.js: this.trans.write(new Buffer([b]));
      lib/thrift/compact_protocol.js: var buff = new Buffer(8);
      lib/thrift/compact_protocol.js: this.trans.write(new Buffer(arg, encoding));
      lib/thrift/compact_protocol.js: var buf = new Buffer(5);
      lib/thrift/compact_protocol.js: var wbuf = new Buffer(wsize);
      lib/thrift/compact_protocol.js: var buf = new Buffer(10);
      lib/thrift/compact_protocol.js: var wbuf = new Buffer(wsize);
      lib/thrift/compact_protocol.js: return new Buffer(0);
      lib/thrift/buffered_transport.js: this.inBuf = new Buffer(this.defaultReadBufferSize);
      lib/thrift/buffered_transport.js: this.inBuf = new Buffer(this.defaultReadBufferSize);
      lib/thrift/buffered_transport.js: var buf = new Buffer(reader.writeCursor + data.length);
      lib/thrift/buffered_transport.js: var buf = new Buffer(bufSize);
      lib/thrift/buffered_transport.js: var buf = new Buffer(len);
      lib/thrift/buffered_transport.js: buf = new Buffer(buf, 'utf8');
      lib/thrift/buffered_transport.js: var msg = new Buffer(this.outCount),
      lib/thrift/framed_transport.js: this.inBuf = buffer || new Buffer(0);
      lib/thrift/framed_transport.js: buf = new Buffer(buf, encoding || 'utf8');
      lib/thrift/framed_transport.js: var out = new Buffer(this.outCount),
      lib/thrift/framed_transport.js: var msg = new Buffer(out.length + 4);
      test/test_driver.js: let buf = new Buffer(arr);
      test/test_driver.js: buf = new Buffer(arr);
      test/test-cases.js: ["testI64", new Int64(new Buffer([0, 0x20, 0, 0, 0, 0, 0, 1]))], // 2^53+1
      test/test-cases.js: new Int64(new Buffer([0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
      ```

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jking3 James E. King III
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: