germanrcuriel/slack-api-client

apiKey is overwritten when instantiating a new client

Closed this issue · 3 comments

holm commented

We had problems in production where wrong tokens where being used, when mutltiple clients where in used at the same time. I was able to reproduce the problem after a lot of trial and error:

describe('testing slack client', function () {
  it('should keep track of tokens', function () {
    const SlackClient = require('slack-api-client');
    const a = new SlackClient('a');
    expect(a.api.channels.slack.apiKey).to.equal('a');
    const b = new SlackClient('b');
    expect(b.api.channels.slack.apiKey).to.equal('b');

    expect(a.api.channels.slack.apiKey).to.equal('a');
  });
});

The last expect fails, since the apiKey for channels on client a is now 'b'.

I have looked at the code, and I am not exactly sure where the problem is, so I unfortunately cannot help with a fix.

Hi @holm. Thanks for the opening the issue! I was able to reproduce the issue. I just published a new version fixing it! 👍

holm commented

That was fast, thanks a lot.

Thanks to you for reporting it! 😉