-
Notifications
You must be signed in to change notification settings - Fork 52
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
Async-listener breaks method dispatch for promise subclasses #112
Comments
I believe this snippet illustrates the underlying problem: function WrappedPromise(executor) {
var p = new Promise(executor);
p.__proto__ = WrappedPromise.prototype;
return p;
}
WrappedPromise.__proto__ = Promise;
WrappedPromise.prototype.__proto__ = Promise.prototype;
WrappedPromise.prototype.then = function then(onFulfilled, onRejected) {
console.log('WrappedPromiseThen');
return Promise.prototype.then.call(this, onFulfilled, onRejected);
};
class P extends WrappedPromise {
then(onF, onR) {
console.log('PThen');
return Promise.prototype.then.call(this, onF, onR);
}
}
(new P(res => { res(42); })).then(v => { console.log(v); }); Async-listener replaces the global promise with its own function-based class. Other modules extend the global Promise using ES6 class syntax. However, extending the function-based wrapper class does not result in the correct dispatch behavior. I think the best approach may be to rewrite the |
New versions of got do not play well with async listener. The bug tracking this issue is here: othiym23/async-listener#112. Got is only a dev dependency used by the system tests so relying on an older version should be fine. PR-URL: #504
@matthewloring Thanks for the ping 😃 I've commented on the PR |
Can we re-opening after revert of the original fix due to #121. I don't have permission. |
I could also just reopen this if you guys think that is better? |
I think the new issue is good |
Test case:
Expected output (and observed when
require('async-listener');
is removed):Observed output:
This issue breaks the got module (by breaking p-cancelable) and can be reproduced with node version 6.x and 8.x.
The text was updated successfully, but these errors were encountered: