Skip to content

JS client: r.connect([host]) → promise, argument not optional #5846

@arve0

Description

@arve0

r.connect is documented as r.connect([host]), but host is not optional and connect must be called with an object. If not TypeError is thrown: TypeError: Cannot read property 'authKey' of undefined.

To reproduce:

const r = require('rethinkdb');
r.connect().then((connection) => {
  console.log('connected');
}).catch((e) => {
  console.error('ERROR:' + e);
});

Line responsible is

        host = hostOrCallback

but should be

        host = hostOrCallback || {}

Full error message:

TypeError: Cannot read property 'authKey' of undefined
    at /Users/arve/git/commentsdb/node_modules/rethinkdb/net.js:941:14
    at tryCatcher (/Users/arve/git/commentsdb/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._resolveFromResolver (/Users/arve/git/commentsdb/node_modules/bluebird/js/main/promise.js:480:31)
    at new Promise (/Users/arve/git/commentsdb/node_modules/bluebird/js/main/promise.js:70:37)
    at Function.<anonymous> (/Users/arve/git/commentsdb/node_modules/rethinkdb/net.js:939:10)
    at Function.connect (/Users/arve/git/commentsdb/node_modules/rethinkdb/util.js:43:16)
    at Object.<anonymous> (/Users/arve/git/commentsdb/index.js:5:3)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:160:18)
    at node.js:445:3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions