wrapCallback doesn't work with single-argument-callbacks
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Description
WrapCallback provides a callback function which expects two arguments:
1. An error/null.
2. The actual value.
This doesn't work with functions like fs.exists or http.get because they call the function only with the result. [See the code in question](https://github.com/caolan/highland/blob/d7fbb1d03c23a8817fb121e34bff40585b2ff964/lib/index.js#L3985-L3993).
This behavior breaks the example of flatFilter():
``` javaScript
var checkExists = _.wrapCallback(fs.exists);
filenames.flatFilter(checkExists)
```
This code will always throw 'Uncaught, unspecified "error" event.'
Contributor guide
Research direction
Start with lib/index.js lines 3985-3993 and trace how wrapCallback handles callback arguments and errors. Reproduce the flatFilter example with fs.exists or http.get, then confirm that single-result callbacks work without breaking the documented error/value callback form or emitting an unspecified error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100