Conversation
|
I've fixed the issue |
|
could you please add a test case for this? |
| if (!constructor && typeof result?.finally === 'function') { | ||
| return result.finally( | ||
| if (!constructor && typeof result?.then === 'function') { | ||
| return result.then( |
There was a problem hiding this comment.
Here we retrieve result.then twice which theoretically not work like JS spec strictly. We'd better write a helper to ensure such subtle semantic. (Not sure whether Node.js already have such internal thenable helpers).
There was a problem hiding this comment.
I mean, if follow JS spec strictly, the code should be:
const {then} = result
if (typeof then === 'function') {
ReflectApply(then, result, [callback])
}Because theoretically result.then could be a getter, and two retrieve could give u different result.
There was a problem hiding this comment.
I also don't understand why checkIsPromise "do not accept thenables that use a function as obj and that have no catch handler" intentionally, this limitation seems wrong to me.
9dc34fa to
da9e49a
Compare
| if (!constructor && typeof result?.then === 'function') { | ||
| return result.then( | ||
| function wrappedTimerifiedPromise(value) { | ||
| processComplete(fn.name, start, args, histogram); |
There was a problem hiding this comment.
One idea which is not relate to the bug directly, but:
currently, now is called in the processComplete (duration = now() - start) , but consider the goal is to calc the time as precise as possible, it may be better to calc it outside like:
const t = now()
processComplete(fn.name, start - t, args, histogram)(also need to modify other related places, omit here)
This could rule out the invoking time of processComplete, in the cases of microbenchmark, such cost can't be ignored.
Fixes: #42743