New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cocaine

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cocaine - npm Package Compare versions

Comparing version 0.4.1-2 to 0.4.1-3dbg

33

lib/channel/channel.js

@@ -32,2 +32,3 @@

this._inBuffer = null
this._traceId = '$$<unknown channel>'
this._hdl = {}

@@ -46,3 +47,3 @@ ;['on_socket_error', 'on_connect',

connect: function(){
debug('connecting channel')
debug(this._traceId, 'connecting channel')
__assert(!this._socket, '!this._socket')

@@ -53,6 +54,6 @@ this._makeSocket()

if(this._socketPath){
debug('connecting channel, path:', this._socketPath)
debug(this._traceId, 'connecting channel, path:', this._socketPath)
this._socket.connect(this._socketPath)
} else if(this._host){
debug('connecting channel, [host,port]:', [this._host, this._port])
debug(this._traceId, 'connecting channel, [host,port]:', [this._host, this._port])
this._socket.connect(this._port, this._host)

@@ -153,3 +154,3 @@ }

"typeof sid === 'number' && typeof event === 'string'")){
debug('bad RPC.invoke message')
debug(this._traceId, 'bad RPC.invoke message')
} else {

@@ -165,3 +166,3 @@ this.on_invoke(sid, event)

"typeof sid === 'number', Buffer.isBuffer(buf)")){
debug('bad RPC.chunk message')
debug(this._traceId, 'bad RPC.chunk message')
} else {

@@ -177,3 +178,3 @@ this.on_chunk(sid, buf)

"typeof sid === 'number'")){
debug('bad RPC.choke message')
debug(this._traceId, 'bad RPC.choke message')
} else {

@@ -189,3 +190,3 @@ this.on_choke(sid)

"typeof errno === 'number', typeof message === 'string'")){
debug('bad RPC.error message', m)
debug(this._traceId, 'bad RPC.error message', m)
} else {

@@ -201,3 +202,3 @@ this.on_error(errno, message)

"typeof code === 'number', typeof message === 'string'")){
debug('bad RPC.terminate message', m)
debug(this._traceId, 'bad RPC.terminate message', m)
} else {

@@ -210,3 +211,3 @@ this.on_terminate(code, reason)

default: {
debug('discarding unknown message type', m)
debug(this._traceId, 'discarding unknown message type', m)
}

@@ -218,3 +219,3 @@ }

__assert(Buffer.isBuffer(buf), 'Buffer.isBuffer(buf)')
debug('channel got data', buf)
debug(this._traceId, 'channel got data', buf)

@@ -227,15 +228,15 @@ if(this._inBuffer){

var m
while(m = unpackMessage(this._inBuffer)){
while(m = unpackMessage(this._inBuffer, this._traceId)){
if(m === _mpFail){
debug('bad message framing')
debug(this._traceId, 'bad message framing')
this.close()
}
debug('worker got message', m)
debug('unpackMessage.bytesParsed', remaining)
debug(this._traceId, 'channel got message', m)
debug(this._traceId, 'unpackMessage.bytesParsed', remaining)
var remaining = this._inBuffer.length - unpackMessage.bytesParsed
debug('remaining', remaining)
debug(this._traceId, 'remaining', remaining)

@@ -245,3 +246,3 @@ this._hdl.message(m)

if(0 < remaining){
debug('remaining buffer', this._inBuffer.slice(unpackMessage.bytesParsed))
debug(this._traceId, 'remaining buffer', this._inBuffer.slice(unpackMessage.bytesParsed))
this._inBuffer = this._inBuffer.slice(this._inBuffer.length - remaining)

@@ -248,0 +249,0 @@ } else {

@@ -12,3 +12,3 @@

function unpackMessage(buf){
function unpackMessage(buf, traceId){
if(buf.length === 0){

@@ -18,2 +18,4 @@ return

traceId = traceId || ''
if(!(buf[0] === 0x93)){

@@ -26,3 +28,3 @@ return fail

debug('parser got method', method)
debug(traceId, 'parser got method', method)

@@ -41,6 +43,6 @@ if(method === null){

parsed += parseInt.bytesParsed
debug('parsed sid,len', sid, parseInt.bytesParsed)
debug(traceId, 'parsed sid,len', sid, parseInt.bytesParsed)
if(!buf[parsed] === 0x91){
debug('buf[parsed] === 0x91 '+buf.slice(parsed).toString())
debug(traceId, 'buf[parsed] === 0x91 '+buf.slice(parsed).toString())
return fail

@@ -56,6 +58,6 @@ }

}
debug('before parseBuffer, parsed', parsed)
debug(traceId, 'before parseBuffer, parsed', parsed)
parsed += parseBuffer.bytesParsed
debug('parseBuffer.bytesParsed', parseBuffer.bytesParsed)
debug(traceId, 'parseBuffer.bytesParsed', parseBuffer.bytesParsed)
unpackMessage.bytesParsed = parsed

@@ -67,4 +69,4 @@

var m = mp.unpack(buf)
debug('mp.unpack.bytes_remaining', mp.unpack.bytes_remaining)
debug('unpacked', m)
debug(traceId, 'mp.unpack.bytes_remaining', mp.unpack.bytes_remaining)
debug(traceId, 'unpacked', m)
if(m === null){

@@ -71,0 +73,0 @@ return m

@@ -8,2 +8,3 @@

var mp = require('msgpack')
var format = require('util').format

@@ -20,2 +21,6 @@ var util = require('../util')

methods:{
_traceId: function(){
return format('$$<service %s[%s]>', this._name, this._id)
},
_send: function(message){

@@ -55,3 +60,3 @@ var buf = mp.pack(message)

connect: function(endpoint){
debug('connecting to', endpoint)
debug(this._traceId(), 'connecting to', endpoint)
if(Array.isArray(endpoint)){

@@ -61,2 +66,3 @@ __assert(typeof endpoint[0] === 'string' && typeof endpoint[1] === 'number', "endpoint is ['host|ip', port]")

var channelHandle = new channel_binding(endpoint[0], endpoint[1])
channelHandle._traceId = this._traceId()
} catch (e){

@@ -73,2 +79,3 @@ if(typeof e === 'number'){

var channelHandle = new channel_binding(endpoint)
channelHandle._traceId = this._traceId()
} catch(e){

@@ -132,3 +139,3 @@ if(typeof e === 'number'){

var _this = this.owner
debug('socket error <%s>', _this._name, _ERRNO[errno])
debug(_this._traceId(), 'socket error <%s>', _this._name, _ERRNO[errno])
var e = makeError(errno)

@@ -150,4 +157,4 @@ _this._closeHandle()

on_choke: function(sid){
debug('choke',sid)
var _this = this.owner
debug(_this._traceId(), 'choke',sid)
var s = _this._sessions[sid]

@@ -161,4 +168,4 @@ if(s){

on_error: function(sid, code, message){
debug('error',sid, code, message)
var _this = this.owner
debug(_this._traceId(), 'error',sid, code, message)
var s = _this._sessions[sid]

@@ -165,0 +172,0 @@ if(s){

@@ -22,2 +22,4 @@

this._methodId = undefined
this._methodName = undefined
this._svcId = undefined
this._args = null

@@ -43,2 +45,7 @@ this._done = false

Session.prototype = {
_traceId: function(){
return util.format('$$%s.%s[%s][%s]', this._svcId, this._methodName, this._methodId, this._id)
},
_resetTimeout: function(){

@@ -50,3 +57,3 @@ clearTimeout(this._callTimer)

pushChunk: function(chunk){
debug('chunk for', this._id, chunk)
debug(this._traceId(), 'recv chunk')
__assert(this._chunk === undefined)

@@ -58,3 +65,3 @@ this._chunk = chunk

pushChoke: function(){
debug('choke for', this._id)
debug(this._traceId(), 'recv choke')
__assert(!this._done)

@@ -68,2 +75,3 @@ this._done = true

} else {
debug(this._traceId(), util.format('callback(null, %j)', this._result))
this._cb(null, this._result)

@@ -73,2 +81,3 @@ }

pushError: function(code, message) {
debug(this._traceId(), 'recv error', code, message)
__assert(!this._done)

@@ -80,4 +89,6 @@ this._done = true

if(typeof this._cb === 'function'){
var err = new Error(util.format('%s\n in service %s method %s\n args: %s\n', message, owner._name, this._methodId, util.inspect(this._args)))
var err = new Error(util.format('%s\n in service %s method %s\n args: %s\n',
message, owner._name, this._methodId, util.inspect(this._args)))
err.code = code
debug(this._traceId(), util.format('callback(Error(%s, %s))', code, message))
this._cb(err)

@@ -89,7 +100,8 @@ }

module.exports.unpackWith = function(unpacker){
return function(mid){
return function(methodId, methodName){
return function(){
debug('================ unpackWith, calling method %s', mid)
var args = slice.call(arguments)
var svcId = this._traceId()
debug(svcId, ':unpackWith<%s-%s>(%j)', methodId, methodName, args)
__assert(this._state === 'connected')
var args = slice.call(arguments)
var sid = this.__sid++

@@ -104,7 +116,10 @@ if(0 < args.length){

S._args = args
S._methodId = mid
S._methodName = methodName
S._methodId = methodId
S._svcId = svcId
this._sessions[sid] = S
debug(S._traceId(), 'session created')
}
}
this.send([mid, sid, args])
this.send([methodId, sid, args])
}

@@ -114,7 +129,8 @@ }

module.exports.unpacking = function(mid){
module.exports.unpacking = function(methodId, methodName){
return function(){
debug('================ unpacking, calling method %s', mid)
var args = slice.call(arguments)
var svcId = this._traceId()
debug(svcId, ':unpacking<%s-%s>(%j)', methodId, methodName, args)
__assert(this._state === 'connected')
var args = slice.call(arguments)
var sid = this.__sid++

@@ -128,7 +144,10 @@ if(0 < args.length){

S._args = args
S._methodId = mid
S._methodId = methodId
S._methodName = methodName
S._svcId = svcId
this._sessions[sid] = S
debug(S._traceId(), 'session created')
}
}
this.send([mid, sid, args])
this.send([methodId, sid, args])
}

@@ -135,0 +154,0 @@ }

@@ -87,3 +87,3 @@

var M = ((_ = def.methods) && _[methodName]) || def.defaultMethod
proto[methodName] = M(mid)
proto[methodName] = M(mid, methodName)
}

@@ -138,2 +138,3 @@

var done = false
var debug0 = debug(this._traceId(), 'serviceConnect')

@@ -150,3 +151,3 @@ if(this._lookingup) return

function _resolve(){
debug('_resolve', _this._name, _this._endpoint)
debug(_this._traceId(), '_resolve', _this._name, _this._endpoint)
if(!_this._client && client === undefined){

@@ -159,4 +160,3 @@ client = new Client()

function _resolveDone(err, result){
debug('_resolveDone', arguments)
debug('svcproto',_this.__svcproto)
debug(_this._traceId(), '_resolveDone', arguments)
if(err) return _handleError(err)

@@ -166,3 +166,2 @@ var p = bakeServiceProto(_this._name, result,

_this.__svcproto || _this.__proto__)
debug('baked proto', p)
_checkIP()

@@ -172,5 +171,5 @@ }

function _checkIP(){
debug('_checkIP', _this._endpoint)
debug(_this._traceId(), '_checkIP', _this._endpoint)
if(Array.isArray(_this._endpoint) && !isIP(_this._endpoint[0])){
debug('not ip:', _this._endpoint[0])
debug(_this._traceId(), 'not ip:', _this._endpoint[0])
dns.lookup(_this._endpoint[0], _lookupDone)

@@ -183,3 +182,3 @@ } else {

function _lookupDone(err, address, family){
debug('_lookupDone', arguments)
debug(_this._traceId(), '_lookupDone', arguments)
if(err) return _handleError(err)

@@ -191,3 +190,3 @@ _this._endpoint[0] = address

function _handleError(err){
debug('_handleError', arguments)
debug(_this._traceId(), '_handleError', arguments)
if(!done){

@@ -198,3 +197,3 @@ done = true

} else {
debug('_handleError called after done', arguments)
debug(_this._traceId(), '_handleError called after done', arguments)
}

@@ -204,3 +203,3 @@ }

function _connect(){
debug('_connect')
debug(_this._traceId(), '_connect')
if(!done){

@@ -211,3 +210,3 @@ done = true

} else {
debug('_connect called after done')
debug(_this._traceId(), '_connect called after done')
}

@@ -214,0 +213,0 @@ }

@@ -11,2 +11,3 @@

var __fsmid = 0

@@ -20,2 +21,3 @@ function define(def){

this._error = null
this._id = process.pid + ':' + (+Date.now()) +'-'+ (__fsmid++)
this.__sid = 0

@@ -22,0 +24,0 @@ }

@@ -5,3 +5,29 @@

var slice = Array.prototype.slice
function formatArgs() {
var args = slice.call(arguments);
var useColors = this.useColors;
var name = this.namespace;
var traceId = args[0]
if(typeof traceId === 'string' && traceId[0] === '$' && traceId[1] === '$'){
args.shift()
traceId = traceId.slice(2)
} else {
traceId = ''
}
args[0] = Date.now() +
' (+' + debug.humanize(this.diff) + ') '+
name + ' ' + traceId + ' ' + args[0]
return args;
}
debug.formatArgs = formatArgs
module.exports = {

@@ -8,0 +34,0 @@ debug: debug,

{
"name": "cocaine",
"version": "0.4.1-2",
"version": "0.4.1-3dbg",
"description": "Node.js framework for Cocaine platform",

@@ -5,0 +5,0 @@ "author": "Cocaine Project <cocaine@yandex-team.ru>",

var hostname = require('os').hostname()
var format = require('util').format
var cli = new (require('../lib/client/client').Client)(['apefront.tst.ape.yandex.net', 10053])
var cli = new (require('../lib/client/client').Client)(['localhost', 10053])

@@ -6,0 +6,0 @@

var mp = require('msgpack')
var cli = new (require('../lib/client/client').Client)(['coca', 10053])
var cli = new (require('../lib/client/client').Client)(['apefront.tst.ape.yandex.net', 10053])

@@ -6,0 +6,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc