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
Closed

Comments

@hvrauhal
Copy link
Contributor

@hvrauhal hvrauhal commented Jan 12, 2015

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

@hvrauhal hvrauhal commented Jan 12, 2015

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

@petkaantonov
Copy link
Owner

@petkaantonov petkaantonov commented Jan 12, 2015

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.