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

Projects
None yet
2 participants
@hvrauhal
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@hvrauhal

hvrauhal Jan 12, 2015

Contributor

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

Contributor

hvrauhal commented Jan 12, 2015

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

@petkaantonov

This comment has been minimized.

Show comment
Hide comment
@petkaantonov

petkaantonov Jan 12, 2015

Owner

Thanks, fixed with the 2.6.3 release

Owner

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