Bug in promisification of get
See original GitHub issueIt looks to me like get doesn’t perform as it should for promises …
const level = require('level');
async function test() {
this.config = {dir: "testleveldb."};
let db = level('testleveldb.Testtable');
await db.put("testkey", "testval");
let res = await db.get("testkey");
console.assert(res === "testval");
}
test();
Should work, i.e. the db.get will return a promise to be awaited. But it errors …
ReadError: get() requires key and callback arguments
Replacing the 'await db.get` line with a callback e.g.
db.get("testkey", function(err, res) {
if (err) { console.log("Err",err); }
console.log("res=",res)
console.assert(res === "testval");
});
Works, so it looks like get is erroneously checking its arguments for a callback when according to the Readme its supposed to allow this to be undefined and return a promise.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Different behaviour when using util.promisify #4305 - GitHub
Do you want to request a feature or report a bug? bug What is the current behavior? test('should return 1', async () =>...
Read more >Javascript: No More callbacks, Use Promisify to Convert ...
We need to convert callback to promise because the promise is more readable and easier to handle.
Read more >Jest doesn't work with util.promisify(setTimeout) - Stack Overflow
This is an interesting question. It gets all the way down to the implementation of core built-in functions.
Read more >Promisification - The Modern JavaScript Tutorial
“Promisification” is a long word for a simple transformation. It's the conversion of a function that accepts a callback into a function that ......
Read more >886848 - Promisify the debugger frontend - Bugzilla@Mozilla
I'm renaming this bug to "Promisify the debugger frontend" since that's what I've been ... and uses promises to make sure things don't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for prompt response … That might be the problem - looks like its using an earlier version of
level
in a different dependency, let me update and I’ll close this issue if it fixes the issue.Feel free to open a new issue with details and a repro, so we can take a closer look at what’s happening there.