Sebastian Templin
Sebastian Templin

Reputation: 1359

AWS IoT Javascript SDK can not create client

I'm using Vue.js, TypeScript, and the aws-iot-device-sdk package and like to subscribe to a IoT topic. This is how I create a new client:

import AwsIot from 'aws-iot-device-sdk';
import { config } from 'aws-sdk';

client = new AwsIot.device({
    region: 'foo',
    host: 'foo',
    clientId: 'foo',
    protocol: 'wss',
    accessKeyId: config.credentials.accessKeyId,
    secretKey: config.credentials.secretAccessKey,
    sessionToken: config.credentials.sessionToken
});

One seconds later I get this console error:

Uncaught TypeError: Cannot read property 'read' of undefined
    at nReadingNextTick (_stream_readable.js)
Uncaught TypeError: Cannot read property 'length' of undefined
    at onwriteDrain (_stream_writable.js)
    at afterWrite (_stream_writable.js)
Uncaught TypeError: Cannot read property 'length' of undefined
    at onwriteDrain (_stream_writable.js)
    at afterWrite (_stream_writable.js)
Uncaught TypeError: Cannot read property '_readableState' of undefined
    at emitReadable_ (_stream_readable.js)
Uncaught TypeError: Cannot read property 'reading' of undefined
    at maybeReadMore_ (_stream_readable.js)

Upvotes: 1

Views: 342

Answers (1)

tomatentobi
tomatentobi

Reputation: 3157

node-libs-browser's implementation of process.nextTick does not accept callback arguments. Just override it inside your main.ts!

process.nextTick = function(callback) {
    const args = [...arguments];

    args.shift();
    setTimeout(() => callback.apply(null, args));
}

UPDATE:

It's fixed in v2.2.1: Commit

Upvotes: 1

Related Questions