Questions tagged [node-promisify]

For questions specific to the node.js built-in utility function: util.promisify(). When using this tag also include the more generic [node.js] tag.

The utility function: util.promisify() was added in version 8. It is used to convert a -based function to a -based one.

Reference:

49 questions
0
votes
1 answer

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 mounted, it opens up the application, but it…
silent92
  • 33
  • 5
0
votes
1 answer

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 always returning Promise { undefined }. If I run…
Vahida Vadiya
  • 144
  • 1
  • 12
0
votes
1 answer

Why don't my promisify and jwt return values or errors?

if(req.cookies.token_name) { try { const decoded = await promisify(jwt.verifiy)(req.cookies.token_name, process.env.jwtsecret); console.log(decoded); } catch (error) { console.log(error); …
kaPa
  • 87
  • 10
0
votes
0 answers

Node.js memcached throwing unhandled promise rejection from within try/catch

I'm using a promisified version of the node.js memcached library for caching. var get = promisify(memcached.get).bind(memcached); var set = promisify(memcached.set).bind(memcached); var add = promisify(memcached.add).bind(memcached); …
0
votes
1 answer

How do I use async/await in a mocha before hook?

I am using node's util.promisify to try and await an fs.readFile result inside a helper function, but the second readFile is never called and I always get a timeout error. From what I can see I am using await correctly, according to the Mocha docs…
GrayedFox
  • 2,350
  • 26
  • 44
0
votes
1 answer

Promisify Express response.render method

I need to create a render method to build html blocks into a string. It seems to work but I used the notorious "new Promise" and I wanted to know if what I've done is either correct or not: async render(req, res) { const locals = await…
0
votes
1 answer

Promisify a function which returns null

This function returns null and I need to promisify it. but I don't understand this code. Can anyone help with this. return iyzipay.payment.create(req, function (err, result) { return('result:'+ result + 'error:'+ err); })
0
votes
1 answer

util.promisify old library call

I've been scratching my head over on how to promisify this call and return data to another function when it becomes available. syno.query('/webapi/query.cgi', { api : 'SYNO.API.Info', version: 1, method : 'query', query :…
ddmunhoz
  • 31
  • 4
0
votes
1 answer

Unit Testing a nodejs function using `fs` wrapped in `promisify`

In the following code I have a function that is looking for a file in the file system based on a provided configuration. const fs = require('fs'); const { promisify } = require('util'); const lstat = promisify(fs.lstat); async function…
Donnie D'Amato
  • 3,832
  • 1
  • 15
  • 40
0
votes
2 answers

Include a Promisified Callback Inside A Promise Resolver?

I'm setting up a GraphQL resolver to call a Braintree endpoint. The Braintree npm package wants to call their endpoint with code that looks like this: braintreeGateway.customer.create({ firstName: "Jen", lastName: "Smith", company:…
VikR
  • 4,818
  • 8
  • 51
  • 96
0
votes
1 answer

Can't Promisify node-ftp Function

I am using the node-ftp library and I would like to promisify certain methods (list() and get()). I am aware that there are promise-based wrappers, but I need to return the readable stream (and not write to a local file) and node-ftp allows…
Alex Webster
  • 707
  • 1
  • 6
  • 21
0
votes
1 answer

Create register: TypeError: Right-hand side of 'instanceof' is not callable Express and Promisify

The following code shows me the error: TypeError: Right-hand side of 'instanceof' is not callable There seems to be a problem here with the es6-promisify library const {promisify} = require("es6-promisify"); exports.register = async (req, res,…
Umbro
  • 1,984
  • 12
  • 40
  • 99
0
votes
1 answer

Promise resolves when it should be catching error

I have a simple node+express app that makes a few async http/get url requests if you visit a certain page. This is to simply get some data from the db, and send that to the view. The routes are handled using a standard separate routes.js…
Sam Sverko
  • 1,480
  • 4
  • 15
  • 32
0
votes
1 answer

Using Node JS utility.promisify() call is not coming back from async callback method

I am trying to use node js promisify to convert the callback to promise inoreder to use await on a async callback function. I tried different ways to pass the parameter and put loggers const {promisify} = require('util'); const callbackFn =…
Lucifer007
  • 107
  • 1
  • 14
0
votes
0 answers

HTTP request not working when done in code

I am making a request and everything is correct but the issue I have is I keep getting a 404 error. but if I copy the parameters and body with that same url to postman it returns a success. I do not know what I am doing wrong. const promisify =…
King
  • 1,885
  • 3
  • 27
  • 84