Leaks detected
throrin19 opened this issue · comments
Hi,
With the version fb@2.0.0, if I run test with lab, I have this error :
The following leaks were detected:__core-js_shared__, @@any-promise/REGISTRATION
It seems that this comes from your library, if I do not use it, the warning goes away.
I try to fix the @@any-promise/REGISTRATION
error by using bluebird instead of any-promise
like this :
const Promise = require('bluebird');
const fb = new FB.Facebook({
versions : 'v2.9',
Promise,
});
But the error is still there.
Judging by the names the leaks aren't in fb itself but in packages we depend on, which might be fixable by using them in a different way. The fact that there are names for them also suggests there should be some sort of info/documentation page explaining how they occur.
Could you point me to the tool/command you used so I can test this myself and see if there is any documentation with more information on these leaks.
I try this with the project Hapi/lab with this command :
lab -C -R -r console
I use this .labrc.js
:
module.exports = {
coverage : true,
threshold : 80,
lint : true,
'coverage-exclude' : ['config', 'build']
};
and this is a test :
const Lab = require('lab');
const sinon = require('sinon');
const Promise = require('bluebird');
const isArray = require('lodash/isArray');
const lab = exports.lab = Lab.script();
const FB = require('fb');
const describe = lab.describe;
const it = lab.it;
const test = lab.test;
const before = lab.before;
const expect = Lab.expect;
describe('Facebook Plugin', () => {
it('Init Facebook', () => {
const fb = new FB.Facebook({
versions : 'v2.9',
Promise,
});
return fb.api('oauth/access_token', {
client_id : '...',
client_secret : '...',
grant_type : 'client_credentials',
})
.then((res) => {
fb.setAccessToken(res.access_token);
return Promise.resolve(fb);
});
});
});
Node 4.x's maintenance window is ending in April and Promises have been available natively since Node 6.x.
Instead of trying to debug the leaks I will consider raising the minimum Node.js version to 6.x and dropping any-promise.
Though I think I'll still support the Promise
option if you wish to explicitly override the Promise library. Not as a way to add Promises where they don't exist, but to give you the option of using a more efficient implementation with better bug handling like Bluebird.