Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COS-interacting script never exits #28

Closed
pzbitskiy opened this issue Aug 22, 2018 · 6 comments
Closed

COS-interacting script never exits #28

pzbitskiy opened this issue Aug 22, 2018 · 6 comments

Comments

@pzbitskiy
Copy link

pzbitskiy commented Aug 22, 2018

Hello,

I run the following code and the script never finishes (does not return back to shell):

const AWS = require('ibm-cos-sdk');
const config = {
    apiKeyId: creds.apikey,
    endpoint: "https://s3.us-south.objectstorage.softlayer.net",
    serviceInstanceId: creds.resource_instance_id
};

let cos = new AWS.S3(config);

function doCreateBucket() {
    console.log('Creating bucket');
    return cos.createBucket({
        Bucket: 'my-bucket-unique-name-112233',
        CreateBucketConfiguration: {
            LocationConstraint: 'us-south'
          },
    }).promise();
}

doCreateBucket().then(
    () => console.log("done")
);

Console output:

[username@localhost bluemix]$ node cos.js 
Creating bucket
done

^C
[username@localhost bluemix]$ node -v
v8.11.3

So... What's wrong with it?

@paul-carron
Copy link
Contributor

This only happens with IAM auth. With hmac, the promise finishes correctly. I'm looking into the cause of this.

@ScottChapman
Copy link

I am seeing this too...

@widget-
Copy link

widget- commented Aug 27, 2018

Looks like it's the preemptive IAM token refresh code: https://github.com/IBM/ibm-cos-sdk-js/blob/master/lib/iam/token_manager.js#L381

@widget-
Copy link

widget- commented Aug 27, 2018

We're looking into some fixes. For now it looks like the workaround is to call process.exit() after the final call.

e.g.:

// es5
doCreateBucket()
    .then((res) => console.log('Response: ' + util.inspect(res)))
    .catch((err) => console.log('An exception occurred: ' + util.inspect(err)))
    .then(() => process.exit(0));

or

// es6
try {
    const res = await doCreateBucket();
    console.log(`Response: ${res}`);
} catch (err) {
    console.log(`An exception occurred: ${err}`);
}
console.log('done');
process.exit(0);

@akosbalasko
Copy link

Same story here...

@paul-carron
Copy link
Contributor

This is resolved in release 1.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants