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

Promise.all leaks node domains #180

Closed
jbellenger opened this issue Mar 9, 2016 · 1 comment
Closed

Promise.all leaks node domains #180

jbellenger opened this issue Mar 9, 2016 · 1 comment

Comments

@jbellenger
Copy link

The Promise inserted by core-js/library/modules/es6.promise.js has different behavior around domains and Promise.all than the builtin nodejs Promise. This is problematic in that there is potential to leak context into the surround scope.

const domain = require('domain');

// core-js promise
(() => {
  const CorePromise = require('core-js/library').Promise;
  const dom = domain.create();
  const promises = [
    dom.run(() => CorePromise.resolve('a'))
  ];

  CorePromise.all(promises)
    .then(() => console.log('corejs promise active domain', domain.active));
})();

// builtin promise
(() => {
  const dom = domain.create();
  const promises = [
    dom.run(() => Promise.resolve('a'))
  ];

  Promise.all(promises)
    .then(() => console.log('builtin promise active domain', domain.active));
})();

Output:

$ node -v
v4.2.2

$ node test.js
corejs promise active domain Domain {
  domain: null,
  _events: {},
  _eventsCount: 0,
  _maxListeners: undefined,
  members: [] }
builtin promise active domain undefined
@zloirock
Copy link
Owner

Hmm, I thought current fallback for domains should solve this problem. I'll explore it. If you have any ideas how to fix it - feel free propose a solution.

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

2 participants