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

Disposer is not invoked when the resource construction contains two nested then's #433

Closed
hvrauhal opened this issue Jan 12, 2015 · 2 comments

Comments

@hvrauhal
Copy link
Contributor

In the following code, resource 2 is not disposed at all with bluebird versions > 2.4.3:

var BPromise = require('bluebird');

function workingGetResource() {
  return BPromise.resolve(1).then(function (x) {
    console.log('Providing resource', x);
    return BPromise.resolve(x)
  }).disposer(function (y) {
    console.log('Disposing resource', y);
  })
}

function failingGetResource() {
  return BPromise.resolve(2).then(function (x) {
    return BPromise.resolve(x).then(function (y) {
      console.log('Providing resource', y);
      return y
    })
  }).disposer(function (z) {
    console.log('Disposing resource', z);
  })
}

BPromise.using(workingGetResource(), function (r) {
  console.log('Using resource', r)
}).then(function () {
  return BPromise.using(failingGetResource(), function (r) {
    console.log('Using resource ' + r + ' that is only disposed when bluebird <= 2.4.2')
  })
});
@hvrauhal
Copy link
Contributor Author

Here's a patch with a failing test:
hvrauhal@4638b81

@petkaantonov
Copy link
Owner

Thanks, fixed with the 2.6.3 release

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