Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Promisification of request module can be affected by previous calls to promisifyAll #98

Description

@sgerace

In httpRequestor.js, the request module is promisified with the { multiArgs: true } parameter as follows:

var request = requestorConfig.request ||
    Promise.promisifyAll(require("request"), {multiArgs: true});

(see here). If the request module has already been promisified using Bluebird without the multiArgs parameter, it will not re-promisify the methods. In this situation, all requests to the API fail with the following error message:

[Smartsheet] 2020-09-03T13:16:39.339Z[  ERROR] Response: Failure (HTTP NaN)
	Error Code: NaN - expecting an array or an iterable object but got [object Null]
	Ref ID: undefined

Here is a simple reproducible example:

var Bluebird = require('bluebird');
var request = Bluebird.promisifyAll(require('request'));

var client = require('smartsheet');

var smartsheet = client.createClient({
    accessToken: ':accessToken',
    logLevel: 'info'
});

smartsheet.sheets.getSheet({
    id: ':id'
}).then(function(sheet) {
    console.log(sheet.rows.length);
});

Since the request module has been deprecated, it might make sense to switch to something like got, which has native promise support.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions