All Questions
Tagged with node.js asynchronous
7,181
questions
0
votes
0
answers
16
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) {
...
0
votes
0
answers
13
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 ...
1
vote
0
answers
17
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 ...
0
votes
0
answers
27
views
The stream in Node.js returning empty
const command = new GetObjectCommand(getObjectParams); ...
1
vote
1
answer
61
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 ...
0
votes
2
answers
34
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: {
...
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)) ...
0
votes
1
answer
68
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 ...
0
votes
1
answer
34
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 ...
0
votes
2
answers
59
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 ...
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 ...
1
vote
1
answer
33
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 ...
0
votes
1
answer
70
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 ...
0
votes
0
answers
49
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 ...
0
votes
0
answers
111
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, ...
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
...
0
votes
1
answer
93
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 ...
0
votes
0
answers
28
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 ...
0
votes
0
answers
73
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 ...
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
...
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) => ...
1
vote
0
answers
55
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 (...
0
votes
1
answer
40
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/...
0
votes
1
answer
159
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 (...
0
votes
0
answers
22
views
I am having an async issue with goOffline() for Fiebase RTDB using node
I have this script that need to be ran using forever.js . I am using firebase and for some reason when we get to the end of the script Firebase tends to stay online. Due to JS not processing code ...
0
votes
1
answer
192
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 ...
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 ...
0
votes
0
answers
45
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....
0
votes
1
answer
89
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 ...
0
votes
0
answers
29
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 ...
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 ...
0
votes
2
answers
105
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 ...
0
votes
0
answers
54
views
Node.js Performance: Detecting Memory Leaks and High CPU Usage
I have written a Node.js API that reads data from collections. Collection containing 1000 records. Each record contains 300 sub-payload data points.
const data = await csvModel['csvFiles'].find({ &...
1
vote
1
answer
435
views
SequelizeConnectionAcquireTimeoutError: Operation timeout
Please understand this scenario and I need the help to solve this issue.
If anyone can help me identify the issue and solve I will reward him on fiverrr upto $15.
I am working with a backend that is ...
0
votes
0
answers
43
views
Iteration through an Iterable Async returns promise instead of result
I've been tearing my hair out on this one. I have situation where I retrieve some values from an Azure App Configuration, then assign them to a single settings property inside of a singleton class.
...
0
votes
0
answers
25
views
can't work with retrieved mongo data in Nestjs because of TS type problem
I have a problem when working with the records in my Nestjs Services or Repositories after retrieving data from a model (no matter what model). Imagine I want to find a User by its ID from my Mongo ...
1
vote
0
answers
320
views
Nodejs ajax sync calls not working from 2024 january (Chrome)
Premise: I know that "sync" is evil and that nobody should use it. I don't expect answers like "don't use sync" or "rewrite it async". I already know! Thanks.
I have a ...
0
votes
1
answer
29
views
How to wait for the result of an asynchronous query
I'm trying my hand at NodeJS server programming in Typscript and I'm having trouble handling asynchronous queries. My server needs to communicate with a MongoDB database running locally.
Here are my ...
0
votes
3
answers
120
views
How to Synchronously Wait for a Successful Fetch in JavaScript? [closed]
I'm trying to perform a synchronous loop until a fetch to a URL is successful.
Here's what I've attempted:
let res = null
fetch("https://jsonplaceholder.typicode.com/users/1").then((...
0
votes
0
answers
99
views
Understanding Node.js Environment: Handling Multiple Customers in WhatsApp ChatGPT Integration
I am handling an automated program integrated with chatGPT into Whatsapp.
The program is triggered whenever I missed a phone call from a customer or in another case I received an email message from a ...
0
votes
1
answer
107
views
Await SyntaxError in nodeJS: await is only valid in async functions and the top level bodies of modules
It may sound silly, but I can't find why I am getting this error:-
C:\node-project\api.testsite\seed\index.js:20
await User.create(user);
^^^^^
SyntaxError: await is only valid in async functions and ...
1
vote
2
answers
88
views
Checking user existence in separate user-service. Make use of JWT user_id or choreography?
So I return with yet another question I'm having about designing my microservices project app.
Imagine we got those two microservices:
user-management (stores user_id + other stuff about user)
posts-...
0
votes
0
answers
13
views
why is last4 after now prints3 and before working
console.log("first");
let a=0
const main =async()=>{
a++
console.log("start" + a);
setTimeout(()=>{
a++;
console.log("time out_--" + a);
...
0
votes
1
answer
142
views
Why is my 'await' line not working as expected?
Here is my code in Node.JS
const fs = require('fs');
const readline = require('readline');
const filePath = 'the/path/to/the/file';
const linesPerChunk = 20;
const readStream = fs....
1
vote
1
answer
135
views
Concurrency problem with Redis in Node.js
Problem
I have a key called stocks in my Redis and its value is 1000. Suppose 300 customers request to buy (100 stocks each) at the same time. In the end, only 10 customers should be able to buy.
...
1
vote
0
answers
26
views
Getting duplicated requests - getServerSideProps
I'm using "next": "13.4.0" with Pages router.
I have an application that uses a payment platform called MercadoPago and i'm making the checkout proccess through this platform. The ...
1
vote
1
answer
118
views
Promise.catch() not catching errors from promise
I'm trying to check a number of conditions, and if one of them is true I want to proceed to a certain callback function. Otherwise, I want to proceed to a different callback function. Some pseudocode ...
-1
votes
2
answers
142
views
Detect whether a function is async (using NodeJS)
This is a simple task in a web browser but in NodeJS it makes no distinction:
console.log({
// 'Function' in browser, but empty string ('') in NodeJS
'(() => {}).constructor.name': (() => {})...
-1
votes
1
answer
830
views
custom error handling in typescript express?
Okay so i have been using javascript to build my APIs for a long time, i decided to start using typescript and as you can imagine, i keep running into errors. I have a custom error handler for when a ...
0
votes
0
answers
31
views
Node.js Does Not Capture All Output from Asynchronous C++ .exe File
Stack Overflow community!
I'm encountering an issue when interfacing Node.js with asynchronous C++ code. I have an executable file written in C++ and compiled into a .exe, which utilizes asynchronous ...