53 questions
1
vote
0
answers
26
views
How do deal with 'setImmediate()' function when migrating callback function to async await?
I am trying to migrate old legacy NodeJS code that looks like:
function x(data, callback) {
doSomethingWithData(data);
if(data.x) {
setImmediate(callback, "A");
}
...
1
vote
0
answers
120
views
Why does TypeScript pick the wrong overloaded function? [duplicate]
I'm using promisify with mysql2's execute method, and when I do so it always seems to pick the last overload even if it doesn't match the parameters I've provided. I've reduced the problem down to ...
0
votes
1
answer
366
views
Am I using promisify() with bind() correctly?
I am writing middleware to return database queries using SQLite3 and Next.js. Here is a snippet of code that I wrote to return the contents of a DB table. It appears to work, and my checks of sources ...
0
votes
1
answer
718
views
throw new TypeError("expecting a function but got " + util.classString(fn)); TypeError: expecting a function but got [object Undefined]
While running node app.js the Express server is connecting properly and the MongoDB is connecting correctly, but I am facing a problem in the node module as mentioned above.
The complete log is pasted ...
0
votes
1
answer
107
views
Promisify `execFile` is not resolving when opening a dmg file
This is an extremely weird bug I'm running into. Basically, I have this execFile:
export const execFile = util.promisify(childProcess.execFile);
When I use this to open up a dmg file that is currently ...
3
votes
2
answers
4k
views
npm error after installing Node.js: Cannot find module 'es6-promisify'
I have installed the latets version of Node.js for Windows. Whatever command I use I always get the same exception, i.e. when I type "npm -v" get this error message:
Cannot find module 'es6-...
0
votes
1
answer
2k
views
Returning Promise { undefined } in NodeJS when making a function call
I am trying to call a function and wait till the function gets data before further statements get executed. I am new to node js and async/await and promises. I tried some solutions but doesn't work it ...
5
votes
1
answer
2k
views
How to mock a promisified and bound function?
I need to write a test for a function in jest.
I have function like following:
async function fun(conn, input){
const connection = conn.getConnection();
....
// some output gets generated ...