postwait / node-amqp

[UNMAINTAINED] node-amqp is an AMQP client for nodejs
MIT License
1.69k stars 357 forks source link

Strict mode error during exchange declaration #395

Closed combatpoodle closed 9 years ago

combatpoodle commented 9 years ago

Problem

Using Node-amqp v0.2.4, Node v0.10.36; RabbitMQ v3.1.3 and v3.5, I'm getting a strict mode error in my connection.on('error', ...) when declaring an exchange:

Connection event error: [TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them] TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
  at Exchange._onMethod (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/exchange.js:108:39)
...

Problem point

On line 108 of exchange.js, the original is this:

"arguments":this.options.arguments || {}

Looks like a similar snippet is used in queue.js - during my use I'm just not hitting it there for some reason.

Workaround

Dropping this.options.arguments || avoids the error.

Much gratitude

You make the world a better place.

Full debug output:

Attempting to connect via AMQP to {"login":"guest","password":"guest","host":"127.0.0.1","port":"5672","vhost":"/","reconnect":false}
connection is { domain: null,
  _events: 
   { connect: [Function],
     data: [Function],
     error: [Function: backoff],
     ready: [Function],
     end: [Function] },
  _maxListeners: 10,
  options: 
   { host: '127.0.0.1',
     port: '5672',
     login: 'guest',
     password: 'guest',
     authMechanism: 'AMQPLAIN',
     vhost: '/',
     connectionTimeout: 10000,
     ssl: { enabled: false },
     reconnect: false,
     clientProperties: 
      { version: '0.2.4',
        platform: 'node-v0.10.36',
        product: 'node-amqp' } },
  implOptions: 
   { defaultExchangeName: '',
     reconnect: true,
     reconnectBackoffStrategy: 'linear',
     reconnectExponentialLimit: 120000,
     reconnectBackoffTime: 1000 },
  connectionAttemptScheduled: false,
  _defaultExchange: null,
  channelCounter: 0,
  _sendBuffer: <Buffer 00 00 00 00 00 00 00 00 48 40 00 00 00 00 00 00 30 44 b2 1e 2b 7f 00 00 69 00 00 00 6a 00 00 00 38 00 00 00 00 00 00 00 70 0e 0a 01 00 00 00 00 3f 77 00 ...>,
  _blocked: false,
  _blockedReason: null,
  socket: 
   { _connecting: true,
     _handle: 
      { fd: -1,
        writeQueueSize: 0,
        owner: [Circular],
        onread: [Function: onread] },
     _readableState: 
      { highWaterMark: 16384,
        buffer: [],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: false,
        ended: false,
        endEmitted: false,
        reading: true,
        calledRead: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        objectMode: false,
        defaultEncoding: 'utf8',
        ranOut: false,
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: true,
     domain: null,
     _events: 
      { end: [Object],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        connect: [Object],
        timeout: [Object],
        close: [Function],
        data: [Function],
        readable: [Function],
        drain: [Function],
        error: [Function],
        secureConnect: [Function] },
     _maxListeners: 10,
     _writableState: 
      { highWaterMark: 16384,
        objectMode: false,
        needDrain: false,
        ending: false,
        ended: false,
        finished: false,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 8,
        writing: true,
        sync: false,
        bufferProcessing: false,
        onwrite: [Function],
        writecb: [Function],
        writelen: 8,
        buffer: [],
        errorEmitted: false },
     writable: true,
     allowHalfOpen: false,
     onend: null,
     destroyed: false,
     bytesRead: 0,
     _bytesDispatched: 0,
     _pendingData: 'AMQP\u0000\u0000\t\u0001',
     _pendingEncoding: 'utf8',
     _idleTimeout: 10000,
     _idleNext: { _idleNext: [Circular], _idlePrev: [Circular] },
     _idlePrev: { _idleNext: [Circular], _idlePrev: [Circular] },
     _idleStart: 1434559283337,
     _monotonicStartTime: 260263,
     pipe: [Function],
     addListener: [Function: addListener],
     on: [Function: addListener],
     pause: [Function],
     resume: [Function],
     read: [Function],
     _consuming: true },
  destroy: [Function],
  write: [Function],
  pause: [Function],
  resume: [Function],
  setEncoding: [Function],
  ref: [Function],
  unref: [Function],
  address: [Function] }
Connection event connect: undefined
connected
Connection event data: <Buffer 01 00 00 00 00 01 4a 00 0a 00 0a 00 09 00 00 01 25 0c 63 61 70 61 62 69 6c 69 74 69 65 73 46 00 00 00 58 12 70 75 62 6c 69 73 68 65 72 5f 63 6f 6e 66 69 ...>
Connection event data: <Buffer 01 00 00 00 00 00 0c 00 0a 00 1e 00 00 00 02 00 00 02 58 ce>
Connection event ready: undefined
conn ready undefined
Connection event data: <Buffer 01 00 00 00 00 00 05 00 0a 00 29 00 ce>
Connection event data: <Buffer 01 00 01 00 00 00 08 00 14 00 0b 00 00 00 00 ce>
command queue declared { domain: null,
  _events: { rawMessage: [Function] },
  _maxListeners: 0,
  channel: 1,
  connection: 
   { domain: null,
     _events: 
      { connect: [Object],
        data: [Object],
        error: [Object],
        ready: [Object],
        end: [Object],
        close: [Object] },
     _maxListeners: 10,
     options: 
      { host: '127.0.0.1',
        port: '5672',
        login: 'guest',
        password: 'guest',
        authMechanism: 'AMQPLAIN',
        vhost: '/',
        connectionTimeout: 10000,
        ssl: [Object],
        reconnect: false,
        clientProperties: [Object] },
     implOptions: 
      { defaultExchangeName: '',
        reconnect: true,
        reconnectBackoffStrategy: 'linear',
        reconnectExponentialLimit: 120000,
        reconnectBackoffTime: 1000 },
     connectionAttemptScheduled: false,
     _defaultExchange: null,
     channelCounter: 1,
     _sendBuffer: <Buffer 01 00 01 00 00 00 1b 00 32 00 0a 00 00 0f 68 75 62 6f 74 2d 72 65 73 70 6f 6e 73 65 73 08 00 00 00 00 ce 6c 61 74 66 6f 72 6d 53 00 00 00 0d 6e 6f 64 65 ...>,
     _blocked: false,
     _blockedReason: null,
     socket: 
      { _connecting: false,
        _handle: [Object],
        _readableState: [Object],
        readable: true,
        domain: null,
        _events: [Object],
        _maxListeners: 10,
        _writableState: [Object],
        writable: true,
        allowHalfOpen: false,
        onend: null,
        destroyed: false,
        bytesRead: 423,
        _bytesDispatched: 229,
        _pendingData: null,
        _pendingEncoding: '',
        _idleTimeout: -1,
        _idleNext: null,
        _idlePrev: null,
        _idleStart: 1434559283347,
        _monotonicStartTime: 260269,
        pipe: [Function],
        addListener: [Function: addListener],
        on: [Function: addListener],
        pause: [Function],
        resume: [Function],
        read: [Function],
        _consuming: true },
     destroy: [Function],
     write: [Function],
     pause: [Function],
     resume: [Function],
     setEncoding: [Function],
     ref: [Function],
     unref: [Function],
     address: [Function],
     channels: { '0': [Circular], '1': [Circular] },
     queues: { 'hubot-responses': [Circular] },
     exchanges: {},
     parser: 
      { isClient: true,
        state: 'frameHeader',
        parse: [Function: header],
        onMethod: [Function],
        onContent: [Function],
        onContentHeader: [Function],
        onHeartBeat: [Function],
        onError: [Function] },
     readyEmitted: true,
     serverProperties: 
      { capabilities: [Object],
        copyright: 'Copyright (C) 2007-2013 GoPivotal, Inc.',
        information: 'Licensed under the MPL.  See http://www.rabbitmq.com/',
        platform: 'Erlang/OTP',
        product: 'RabbitMQ',
        version: '3.1.5' },
     _outboundHeartbeatTimer: null,
     _inboundHeartbeatTimer: null },
  _tasks: [],
  name: 'hubot-responses',
  _bindings: {},
  consumerTagListeners: {},
  consumerTagOptions: {},
  options: { autoDelete: true, closeChannelOnUnsubscribe: false },
  _openCallback: [Function],
  state: 'open' }
Connection event data: <Buffer 01 00 01 00 00 00 1c 00 32 00 0b 0f 68 75 62 6f 74 2d 72 65 73 70 6f 6e 73 65 73 00 00 00 00 00 00 00 00 ce>
Connection event error: [TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them] TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
  at Exchange._onMethod (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/exchange.js:108:39)
  at Exchange.Channel._onChannelMethod (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/channel.js:85:12)
  at Connection._onMethod (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/connection.js:443:28)
  at AMQPParser.self.parser.onMethod (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/connection.js:136:12)
  at AMQPParser._parseMethodFrame (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/parser.js:363:10)
  at frameEnd (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/parser.js:93:16)
  at frame (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/parser.js:78:14)
  at AMQPParser.header [as parse] (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/parser.js:64:14)
  at AMQPParser.execute (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/parser.js:137:21)
  at Connection.<anonymous> (/home/vagrant/docker/hubot/node_modules/simple-message-helper/node_modules/amqp/lib/connection.js:174:21)
  at Connection.emit (events.js:117:20)
  at Socket.emit (events.js:95:17)
  at Socket.<anonymous> (_stream_readable.js:765:14)
  at Socket.emit (events.js:92:17)
  at emitReadable_ (_stream_readable.js:427:10)
  at emitReadable (_stream_readable.js:423:5)
  at readableAddChunk (_stream_readable.js:166:9)
  at Socket.Readable.push (_stream_readable.js:128:10)
  at TCP.onread (net.js:529:21)
combatpoodle commented 9 years ago

Apologies - PICNIC.

rpadovani commented 8 years ago

Same problem here, but dropping arguments doesn't solve the issue.