question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Async Extensions and Filter in NodeJS environment

See original GitHub issue

Do async methods work in Nodejs? I cannot get them working with Extensions or Filters.

this.nunjucksEnv.addFilter('lookup', function(name, callback) This gets no callback function passed to the anonymous function.

When trying an Extension the run method does get a callback function but if I do not call it immediately nunjucks just skips over it. If I add a console.log() to the async call in the run method, and in the nunjucks.render callback the log from the render callback ALWAYS fires first. I cannot figure out if this functionality just isn’t well tested. ’

Sorry, I cannot post code examples as they are fragments scattered throughout the framework (Sails.js)

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
oyydcommented, Dec 10, 2014

@etx It seems that you didnt’t

pass true as the third argument to addFilter

env.addFilter('lookup', function(name, callback) {
    db.getItem(name, callback);
}, true);

I’m not sure. Any fragments would be helpful.

0reactions
etxcommented, May 2, 2015

Just tested it. Working now in the master branch. Thanks for the fix!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use async functions with Array.filter in Javascript
Async filter with map. The async version is a bit more complicated this time and it works in two phases. The first one...
Read more >
Node.js v19.3.0 Documentation
AsyncLocalStorage tracks async context; process.getActiveResourcesInfo() tracks active resources. The node:async_hooks module provides an API to track ...
Read more >
Async.js
Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use ...
Read more >
How to use promises - Learn web development | MDN
Promises are the foundation of asynchronous programming in modern JavaScript. A promise is an object returned by an asynchronous function, ...
Read more >
How to use Array.prototype.filter with async? - Stack Overflow
There is no way to use filter with an async function (at least that I know of). The simplest way that you have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found