Skip to content

Commit da44821

Browse files
ramsgoliMylesBorins
authored andcommitted
doc: clearify promisify behavior for bad arguments
Currently the documentation states that promisify() will result in undefined behavior if bad arguments are passed. This is not necessarily the case, since the behavior is well defined, but just not useful. PR-URL: #17593 Fixes: #17569 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 26025de commit da44821

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

doc/api/util.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,10 @@ If there is an `original[util.promisify.custom]` property present, `promisify`
512512
will return its value, see [Custom promisified functions][].
513513

514514
`promisify()` assumes that `original` is a function taking a callback as its
515-
final argument in all cases, and the returned function will result in undefined
516-
behavior if it does not.
515+
final argument in all cases. If `original` is not a function, `promisify()`
516+
will throw an error. If `original` is a function but its last argument is not a
517+
Node.js style callback, it will still be passed a Node.js style callback
518+
as its last argument.
517519

518520
### Custom promisified functions
519521

@@ -548,6 +550,8 @@ doSomething[util.promisify.custom] = (foo) => {
548550
});
549551
};
550552
```
553+
If `promisify.custom` is defined but is not a function, `promisify()` will
554+
throw an error.
551555

552556
### util.promisify.custom
553557
<!-- YAML

0 commit comments

Comments
 (0)