Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
-2 votes
0 answers
65 views

The value of count is changing . why is that happening? [closed]

For this code for a playwright test case, both the if condition and the else condition runs when the count value is 5. I am not updating the count value anywhere or re-fetching it. Does NodeJS does ...
Raider_Knight's user avatar
0 votes
0 answers
35 views

Async context tracking, async_hooks

I'm trying to better understand the output from node async_hooks. It's not giving me the output I expect. Specifically, I'd expect that each new async function creates a new asynchronous context. So ...
libby's user avatar
  • 634
0 votes
2 answers
88 views

Nodejs behavior with multiple I/O calls

I understand that nodejs uses libuv library for I/O tasks. By default libuv uses four threads for handling I/O tasks. I am trying to understand the behavior of libuv when more than four I/O tasks are ...
ariko stephen's user avatar
2 votes
0 answers
30 views

How work the limited parallelism in node.js

I'm reading the node.js documentation, and I don't understand the explanation of the asynchronous flow: https://nodejs.org/en/learn/asynchronous-work/asynchronous-flow-control. Indeed, the last ...
Truc Truca's user avatar
3 votes
1 answer
62 views

Question about Node js infinite recursion and async/await behavior [duplicate]

I've been trying to make an infinite loop in Node js, and came across this problem. I experimented a bit and came up with these three functions. async function rc1(){ rc1(); } //-> stack ...
minyoung heo's user avatar
0 votes
1 answer
47 views

Node.js visitor count increments multiple times on page reload (issue with fetch or asynchronous request)

I’m trying to implement a visitor counter on a SPA using Node.js and express. The visitor count is stored in a text file (count.txt), and I have an API endpoint (/api/visitor-count) that both ...
Kaine Odurukwe's user avatar
-5 votes
2 answers
70 views

How is the promise settled by the time it is logged?

I have the following code: async function get_exam_score() { const exam_score = Math.random() * 10; if (exam_score < 5) { throw("You failed"); } } const promise = ...
Oriol Serrabassa's user avatar
0 votes
0 answers
77 views

How to make async function to sync in NodeJS 22 without Fibers?

How to make async TOP-level function to sync in NodeJS 22 without Fibers? console.log("aaa"); const asyncFn = new Promise((resolve) => {setTimeout(() => {reject("bbb")}, 100)}...
klaucode's user avatar
  • 330
1 vote
1 answer
44 views

Why doesn't db.collection() in my Node.js-MongoDB function run at the correct time?

I have the following code using a MongoClient getting called twice: async function readWhileRunning(dbName, collectionName, query, projection) { const collection = await getCollection(dbName, ...
D.W.'s user avatar
  • 39
0 votes
1 answer
44 views

How to use async, await, and resolve()

I'm trying to execute query and get the result, and when the query is all done, execute 'sendSoapMessage(soapMessageJson)'. However I find out everytime I run the this program, soapMessageJson is ...
Chihyun Ahn's user avatar
-1 votes
2 answers
263 views

Promise vs async/await - is it really just syntactic sugar?

It's often said that async/await is just syntactic sugar over promises, and we can re-write code using one approach to use the other. Let's say I have this piece of code using promises: async function ...
Marek Mezei's user avatar
1 vote
1 answer
160 views

Modifying response body from target proxy through http-proxy-middleware

I am trying to modify HTML body response of proxied target url, but my res.send method is not executing because onProxyRes function is not waiting the proxyRes.on('end', () => { event. const ...
Rang's user avatar
  • 13
0 votes
1 answer
32 views

AWS Elastic Beanstalk Load Balancer scales-in instance even thoguh there are still async processes running on it

I have an AWS Elastic Beanstalk worker environment which processes some data in Node.js based on SQS messages or Cron-Jobs. One of the Cron-Jobs is running a main process (currently taking 20~ minutes)...
Zytro's user avatar
  • 15
0 votes
0 answers
21 views

Don't know how to get a simple node/redis/express key with async

I am using node redis express and I want to get a simple redis key. Unfortunately I am always stuck with "Promise <pending>". Between "async/await, promise resolve then catch"...
Gilles's user avatar
  • 29
0 votes
1 answer
65 views

How to apply the DRY principle to async/await functions without encountering excessive overhead?

I have two async functions which duplicate a lot of code with each other, and I'm trying to figure out a way to break this duplicate code out into an alternate function which is called by both ...
eltdrgntmr's user avatar
0 votes
0 answers
14 views

Problem Calling Youtube upload API from AWS Lambda Async Function [duplicate]

Hi New to nodejs here. I am trying to upload youtube videos using GoogleApls SDK. The problem is the SDK method supports callback function. Buy My AWS lambda is an async event handler and I cant ...
Utsav Gupta's user avatar
  • 3,971
0 votes
1 answer
214 views

Twilio serverless function async operations execute order problem

What I'm trying to do: Incoming call from user would trigger a Digits Gather (No problem) After receiving the Digits, Say something to the user Play music while fetching phone number from an API ...
Slodin's user avatar
  • 89
0 votes
0 answers
26 views

In Node.js, do asynchronous file read/writes execute synchronously once started?

An async function in Node will only start executing in a future event loop. But once it starts, it will finish completely before the loop continues. The only exception, of course, being if that ...
Isaac King's user avatar
0 votes
1 answer
35 views

Node.js library that just loads DOM and scripts but can handle async

I am trying to load a page to scrape that loads the data I need only after multiple recursive async script loads. But due to the count of pages and items, can't use things like Puppeteer or Selenium. ...
Ethan Nichols's user avatar
0 votes
0 answers
51 views

NodeJs SplunkSDK Get Api getting 500 Internal server error before the actual response received

I am new to Node js. I am using NodeJS pm2 and [email protected]. Requirement is to get splunk data as a response. module.exports.executeSearch = function (query, params, cb) { ...
Anand Suryavanshi's user avatar
0 votes
0 answers
17 views

Self-written Tasks Queue and awaiting for specific task

Good evening! I've been busy writing a task queue using Node.js for my pet projects, which allows me to wait for a specific task to be completed. The queue works well until it receives a large ...
Neuroborus's user avatar
1 vote
0 answers
20 views

Trying to run tasks in parallel but sync the total, cannot return Promise [duplicate]

I've been trying for a while but cannot figure it out. I'm trying to run a nodejs program that pings all device on the network and return the function. I have all the "pink" tasks running ...
Andrew Rendon's user avatar
0 votes
0 answers
47 views

The stream in Node.js returning empty

const command = new GetObjectCommand(getObjectParams); ...
luminaries's user avatar
1 vote
0 answers
91 views

Seeking Efficient Solutions for Handling Asynchronous File Operations in Node.js

I'm currently developing a Node.js application that requires managing a high volume of asynchronous file operations like reading, writing, and deleting. As I scale up these operations, I'm running ...
Hiren Kalariya's user avatar
0 votes
2 answers
38 views

How to return data in SOAP from Promise

I created a SOAP server in Node.js const soap = require('soap'); const http = require('http'); const XMLWriter = require('xml-writer'); const service = { ImpDispatcherService: { ...
Wernfried Domscheit's user avatar
0 votes
0 answers
19 views

NodeJS await moveing on before function returns [duplicate]

i am downloading images using this function (downloads 30 images) async function downloadImages(imagesList) { imagesList.forEach(async element => { if (!checkForImage(element.filepath)) ...
YelloElefant's user avatar
0 votes
1 answer
176 views

Is there a way to create async tasks with delay, containing the Strapi object as dependency?

After an endpoint was reached, I want to execute a service after a defined expiration time. That means that I need to use the Strapi instance. Is there a way to create like a CRON job maybe, but that ...
Raph Mrci's user avatar
0 votes
1 answer
43 views

Using await/async functionality in a forEach loop of a firebase query result

I have an Node.js function which queries multiple firebase collections. I want to iterate over a collection result set which will query another collection for each object returned. async function ...
MattJ's user avatar
  • 141
0 votes
2 answers
118 views

How can I terminate a function process when an event occurred

everyone, there is a task, where I need to terminate a function process when an event occurs. Normally, when throwing an error in anything inside the process, for example, throwing an error from the ...
Mahmoud Y3c's user avatar
0 votes
0 answers
15 views

How to Synchronizing Data Extraction with Asynchronous Page Navigation | Puppeteer

Lets say I have a page which scrap data for table rows and each row has a button which open new page(like an image viewer) to get the image url using nodejs and puppeteer. After clicking the button in ...
Libra Larow's user avatar
1 vote
1 answer
35 views

Chaining async class methods, Where and Why does the Scope Change?

I wrote a class module that has async methods, and now im trying to chain the methods using .then() the scope of 'this' changes somewhere along the line and i then have to bind the function back to ...
Koza's user avatar
  • 111
0 votes
1 answer
132 views

How to handle multiple async functions when fetching for emails and attachments with IMAP and javascript

I am using IMAP library and javascript to fetch for emails. My plan is the following: Fetch for the emails by email, subject, and a time range. Look for the emails number. For each email, I need to ...
daniel sas's user avatar
0 votes
0 answers
73 views

developing a webhook receiver, it needs to handle time-consuming operations while ensuring a quick response. Any tips on how to achieve both?

As a webhook receiver, I'm tasked with handling time-consuming operations while also ensuring a prompt response to the webhook. What are some effective strategies to achieve both efficiently? Any ...
ishak MP's user avatar
0 votes
0 answers
131 views

SyntaxError: Unexpected token 'async' when index.js file called

I have a node.js app running locally in netbeans. Its entry point is an app.js file: "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ...
user1518003's user avatar
0 votes
0 answers
21 views

What is my problem with updating data without auto-updating the page?

The problem with updating data without auto-updating the page please help with this, I provide the code below if possible, tell me what I'm doing wrong and how to avoid it in the future frontend ...
Алексей Черман's user avatar
0 votes
1 answer
140 views

Prevent blocking the event loop on sync operations

The company I work for has a micro service which handles 300 requests per second, among 30 NodeJS pods. The metrics in DataDog showed high latency and cpu usage today, when there was a peak in ...
Daniel Cohen's user avatar
0 votes
0 answers
36 views

Handling thousands of async POST requests in Express.js

I've encountered an issue with my Node.js Telegram bot. The bot is responsible for sending approximately 1000 requests per second. Given Node.js's reputation for fast request handling, it seemed like ...
Fəqan Çələbizadə's user avatar
0 votes
0 answers
122 views

Node.js: ffmpeg command not waiting for other ffmpeg command promise to be resolved

I am trying to node.js program, in which fluent-ffmpeg first converts an input-mp4-file to an mp3 file and after that fluent-ffmpeg command should trim the mp3 file (for example only 0:12 - 0:48). I ...
Kollegah der Boss's user avatar
0 votes
0 answers
28 views

How to handle asynchronous code in a for-loop nodejs? [duplicate]

I have an upload function as so: const upload = async (req, res) => { let fileData = []; if (req.files) { // Save image to cloudinary let uploadedFile let buffer ...
gerard's user avatar
  • 541
0 votes
0 answers
41 views

about nodejs async function [duplicate]

i'm learning nodejs, here is my confusion: enviroment: os:windows nodejs: v18.19.0 code: const sleep = (seconds) => { const milliseconds = seconds * 1000; return new Promise((resolve) => ...
qwrdxer's user avatar
1 vote
0 answers
70 views

How do I return/emit *really* asynchronously from a C++ node-addon-api (or N-API) to Node?

The situation is as follows: my JavaScript shall start an external hardware process via a node-addon-api call into a C++ library. That hardware process runs for an indeterminate amount of time and is (...
Vroomfondel's user avatar
  • 2,898
0 votes
1 answer
55 views

Failed to serialize user into session, passport.js local strategy in express

Checking a user base from mysql when logging in, I am getting the following error from passport.js: Error: Failed to serialize user into session at pass (/NodeJS/Projects/user-management/node_modules/...
IoT-Practitioner's user avatar
0 votes
1 answer
188 views

How to create a chart in pdf using node js

I have added the structure of my code using Nodejs. Using Nodejs I have added the data to create a pdf report. Using the same data values I need to create a chart in pdf const generatePdf = async (...
CodeBox's user avatar
  • 51
0 votes
1 answer
266 views

Cancel/Abort an async function

There is an express server on Node js The client can create a task in which some processes are executed (cycles, communication with the database, etc.) Communication between the client and the server ...
Wallo's user avatar
  • 3
0 votes
0 answers
59 views

Why does switching the position of async code cause infinite execution in node.js?

In the code below, I try to Connect a WebSocket client to a WebSocket server Connect the socket client to a socket server with different orders. In the promise1, the order of connection is: Connect ...
Shu Chang's user avatar
0 votes
0 answers
49 views

Parallel aync await instead of Promise.all

Take a look at the below code, it uses async and await to execute a list of promises. But they will execute sequentially meaning once promises[0] resolves then only the execution of promises[1] starts....
insanely_sin's user avatar
  • 1,026
0 votes
1 answer
97 views

Running node child processes asynchronously in a loop and receiving stdout results after loop ends

I have the following sample code... const { exec } = require('child_process'); const Main = async () => { const ret = await GetAllItems(); console.log('results', ret); }; const ...
RACO's user avatar
  • 1
0 votes
0 answers
31 views

A Question About Net Module For Handling Messages in the Back-end

In Node.js, I designed my own custom protocol for handling messages using net module; however, I'm not sure whether this code saves the messages to the database real-time or not. That is, I want to ...
user avatar
0 votes
1 answer
21 views

eCom website(Bootstrap UI and JS libraries) accessed on a BS hosted mobile device tested by Selenium script is failing at random element each time

The client runs a eCommerce web site developed with BootStrap UI framework and backed by SAP. This desktop website is used not only on desktop but also with mobile devices. In order to test the ...
user avatar
0 votes
2 answers
146 views

Given asynchronous function, need help trying to write a function to return new time limited version of input function

Here are the challenge directions: Given an asynchronous function fn and a time t in milliseconds, return a new time limited version of the input function. fn takes arguments provided to the time ...
Boo Shorty's user avatar

1
2 3 4 5
144