Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
-1 votes
0 answers
120 views

Nested async-await with promise all loops behaviour not understandable [closed]

I need to group specific consecutive duties of each user based on certain flags. For instance, in my case, I have duty flags with values of "s" and "v." If I have two consecutive ...
vikrant chauhan'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
1 vote
2 answers
110 views

Sequence of promise.race() in the event loop

This code, below, executes as a result: script start promise1 promise2 script end promise3 race: A Chrome version 131.0.6778.26, and node environment 22.4 both give the same result Why is it that “‘...
ctrl team's user avatar
1 vote
0 answers
22 views

Why puppeteer blocks callbacks from execution?

This code as it is opens the browser and read a txt file line by line: line 1 line 2 line 3 Stream closed The thing I don't understand is why placing const browser = await puppeteer....
daego's user avatar
  • 319
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
0 votes
2 answers
53 views

Using promise.all with .then

I want to use await Promise.all with axios so that the requests can be sent concurrently. I have a map with the key as an id, and the value as an url. I want to retain the output also in a similar map,...
10may's user avatar
  • 380
-1 votes
1 answer
80 views

Does iterating over promises actually runs them?

While working with googleapis library with a coworker, I've stumbled onto this error: Uncaught GaxiosError Error: request to <gmail api url> failed, reason: connect EMFILE <xxx.xxx.xx.xxx:xxx&...
RinnieR's user avatar
  • 267
0 votes
2 answers
66 views

nodejs promise return before the execution of the function

I am trying to call fetch method in the promise.allSettled. But the method return the value as empty. fetch is taking time and the response is returned before. Desired result: I want all the images ...
dishank goyal's user avatar
0 votes
0 answers
81 views

How to Resolve Linting Errors Related to Promise Handling in TypeScript with ESLint?

I'm currently working on a Node.js application using TypeScript and Prisma. While trying to implement a database connection and server startup logic, I'm encountering linting errors related to promise ...
Sami Ali's user avatar
  • 147
1 vote
1 answer
38 views

Catching exceptions with async await and avoid unhandledRejection [duplicate]

I have a larger use case that I narrowed down to the following code snippet. This code might not make a lot of sense however this is just to demonstrate the issue I have. I am trying to catch the ...
ryan's user avatar
  • 11
0 votes
0 answers
35 views

Promise.race not firing reject promise

I am trying to use a Promise.race to forcebly timeout a function With the setup below I would expect the code below to return "value b"; the method getValues takes more time to respond than ...
Jimmer Berenstein'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
-1 votes
2 answers
121 views

How can I use await or promise on MySQL call in Twilio serverless functions?

I am using two serverless functions within the Twilio console that call each other to make a openai-powered voice chat. The first, /transcribe, is triggered by an incoming call. I make a successful ...
Michael7S's user avatar
0 votes
1 answer
2k views

Warning: Detected unsettled top-level await

The following code results in error Warning: Detected unsettled top-level await. I don't understand why all of a sudden this block is throwing error when it was working just an hour ago. Didn't make ...
Inder's user avatar
  • 2,096
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
2 answers
108 views

Calling .then within a new Promise() javascript [duplicate]

I've learned javascript async/await before learning promise.then() syntax, and I am now attempting to go back and learn promise.then(). I currently have the following code let getDatabaseData = async (...
JackG's user avatar
  • 73
0 votes
1 answer
45 views

promise.all with loop still get pending in node.js

This app function is about uploading multiple images, the image upload API can only upload one image each time. when uploading multiple images, trying to loop over the images and sequentially upload ...
user824624's user avatar
  • 8,080
-1 votes
1 answer
55 views

how to collect returned results of promises

as shown in the below posted code, for the array geoTIFFsFileNames it contains five files' names. for the number of items in the latter array, i want to invoke the webservice WSGeoTIFFAsBlobStreamer, ...
Amr's user avatar
  • 33
-2 votes
1 answer
45 views

await does not suspend the execution till it finishes [closed]

for the below posted code, despite i am using await before Promise.all, the execution of the code does not wait till await Promise.all finishes first. what happens is, the code that contains: .then(...
Amr's user avatar
  • 33
0 votes
0 answers
27 views

Can I use promises to speed up a computational process so that I can create parallelism in it? [duplicate]

I have intense CPU consuming computations that need to be done and then written to file. I know that I can use promises to create parallelism in writing and reading files, since it is an I/O operation....
Meric Gunduz'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
2 votes
1 answer
210 views

Turn not awaited unhandled erroneous promise into warning @ processTicksAndRejections (created by throw error in "then")

there is no await on top-level allowed and my expectation was that the error thrown below would be logged as warning only but it turns out to be a blocker for completion, i.e. upon statement await ...
CSeitel's user avatar
  • 63
0 votes
3 answers
123 views

javascript MySQL - using Promise-await-async constructs, can't get code to wait for query completion

I've tried multiple versions of example code but can never seem to get something that guarantees completion of the query set before other code commences. I was under the impression that 'await' makes ...
user55836's user avatar
0 votes
0 answers
41 views

NodeJS - Best Practice to process a huge text file and for each row, fire off an API requests, and write an output file (See Example Below)

I am new to concept of "promises" and seeking an enterprise grade or best practice to process a huge text file (1GB max) in NodeJS and then use each row to fire off an API request. The goal ...
Anx's user avatar
  • 13
0 votes
1 answer
131 views

How/why does Mocha suppress unhandled promise rejections, and how can I prevent it from doing this?

Node.js's default behaviour when a promise rejection is unhandled is to terminate the process. node:internal/process/promises:288 triggerUncaughtException(err, true /* fromPromise */); ...
s100's user avatar
  • 21
1 vote
1 answer
64 views

Node js promise all multiple api calls in loop

I'm new to Node js. Here I'm calling multiple api calls in Async. But I want to return promise once all calls are finished. function getChunkBatchDetailsResponse$(id, baseUri, ) { return new ...
vijred's user avatar
  • 75
1 vote
3 answers
106 views

Why do we get an uncaught error, when a promise is rejected before the rejection handler is locked in?

I am trying to catch the rejection reason of an already rejected promise, but I am getting an uncaught error. I have spent some time studying promises, but still do not understand why the error occurs....
Magnus's user avatar
  • 7,829
2 votes
2 answers
286 views

Do callbacks from I/O operations that return promises go to the I/O queue or the microtask queue in Node?

I'm just learning the details of how the event loop in Node works. I learned that the promise queue takes priority over the timer queue, which takes priority over the I/O queue. async function ...
J Booth's user avatar
  • 21
2 votes
1 answer
51 views

I have no idea why setTimeout wrapping promise not working as i expected

I have this code. const testArray = [1, 2, 3, 4, 5]; const test = async () => { return Promise.resolve().then(() => { console.log("Testing console log: ", new Date()); }); };...
Jaeho Lee's user avatar
  • 523
1 vote
2 answers
41 views

Promise all to map or object

I have some sequalize promises. private loadFilterMetaData(): Array<Promise<any>> { const country = CatalogCountry.findAll(); const firm = CatalogFirm.findAll(); ...
Sergei Illarionov's user avatar
1 vote
0 answers
36 views

How to do computation in parallel with an S3 Node sdk call to server

I have a nodejs application which adds a raw file in an S3 bucket and also processes it. These two actions are independent but used to run in series. In order to improve the performance, I wanted to ...
alikn's user avatar
  • 11
1 vote
1 answer
90 views

populate my throw object with error message in json response

I want to populate my error object {'status': response.status, 'msg': ''} with the error message present in the JSON Response of the API if there is any, otherwise throw the error object without any ...
kajezevu's user avatar
-1 votes
1 answer
70 views

JavaScript Promise handlers schedule behaviour

Given this Promise chain. function getData() { return new Promise((resolve) => { // ... }) .then((data) => data.someData) .then((rawData) => processData(rawData)) .catch((...
kekerinho's user avatar
0 votes
0 answers
102 views

NodeJS: why are Promises leaking memory?

Dev environment: NodeJS version 18.9.0 (Windows) Production environment: RaspberryPi (Latest Raspbian, NodeJS) I am trying to continuously poll a remote device over a TCP port using the built-in ...
Ryan Griggs's user avatar
  • 2,758
0 votes
0 answers
23 views

Google Cloud Functions Gen 1 - HTTP trigger - NodeJS - promises - unhandled rejections [duplicate]

Question about handling promises in HTTP triggered CLoud Functions for GCP. Especially gen1 https://cloud.google.com/functions/docs/bestpractices/tips#do_not_start_background_activities There's this ...
Nickname0222022022's user avatar
0 votes
0 answers
34 views

Promises: loop an array [duplicate]

I created a node script that contains a main function that needs compute a result. Basically there is an array of strings and I need to loop on this array and for each values, call a promise function ...
marielle's user avatar
  • 438
0 votes
1 answer
45 views

Using Node.js, ubuntu, console.log does not appear during a Promise https.request, until, completion. How to flush or see in realtime?

On server side Node.js I have a simple http.request ... this is in a simple script.js being run on the shell. async function postRequest(_options, data) { return new Promise((resolve, reject) =>...
Fattie's user avatar
  • 12.3k
1 vote
1 answer
183 views

Promise.race not working on custom function

I have a small Node.js application that tries to deobfuscate a dataset of Javascript source code using synchrony. The synchrony.deobfuscateNode(ast) function returns a promise, thus I implemented a ...
GRoutar's user avatar
  • 1,425
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
-1 votes
1 answer
55 views

express js with synchronous function, freezing web

I am building an app with express, and I realized I made a mistake with what I think Promises this is module.js module.exports = function(arguments){ for(let k =1; k < something.length; k++){ ...
unbaym's user avatar
  • 47
1 vote
0 answers
216 views

Cancel other promise execution on Promise.race reject

I am developing an asynchronous Node.js app that implements Promise.race for a portion of its logic: async function callDeobfuscator(ast) { const withTimeout = (promise) => { let timeoutPid; ...
GRoutar's user avatar
  • 1,425
0 votes
0 answers
49 views

catch block for promise inside promise, [duplicate]

I push many promises to an array and then I wait with Promises.all() for all them to resolve. yet if I reject one of them, the whole program crashes, instead of getting just an error log or a reject ...
unbaym's user avatar
  • 47
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
0 votes
2 answers
152 views

Why I get Uncaught Error even after .catch()?

Here is the code: function sleep(ms:number) { return new Promise((resolve:any,reject:any) => setTimeout(resolve,ms)) } async function errorFunc(): Promise<void> { await sleep(2000) ...
Illia's user avatar
  • 124
0 votes
2 answers
75 views

Main and Renderer handling promises, but Preload can be non-promise?

Considering the renderer and main are handling promises, will the code below force the process to become synchronous if openFile() is not also set to async await? contextBridge.exposeInMainWorld('...
oldboy's user avatar
  • 5,964
1 vote
1 answer
595 views

Does executing sync code in the same Promise.all as async code have any performance benefit?

I have a piece of middleware. It gets reports on data from 3 different endpoints in a Promise.all as its first step. const keys = ['a', 'b', 'c']; const getDataFromEndpoint = async (key) => { ...
GorgonFreeman's user avatar
0 votes
3 answers
76 views

why is the error not being processed in async function?

const promiseAllAsyncAwait = async function() { if (!arguments.length) { return null; } let args = arguments; if (args.length === 1 && Array.isArray(args[0])) { args = args[0]; ...
123123123123's user avatar
1 vote
0 answers
87 views

Node.js Event Loop Order Misunderstanding Between setTimeout() and Promise.resolve() in Versions Prior to v11

I'm exploring the intricacies of the Node.js Event Loop, Timers, and process.nextTick() in versions predating v11, such as v10.19.0 - without higher priority of microtask and nexttick. I'm referencing ...
hunglt.ee's user avatar
0 votes
1 answer
114 views

NodeJS Say Module speak function does not speak when placed in a loop

I am creating a nodeJS application that takes a message from the Character.AI API and then passes that message into the say module’s speak command. Before I just put the message into the speak command,...
pk pulse fall's user avatar
0 votes
1 answer
103 views

JavaScript, Promise, what's wrong with it?

I'm very new to Promises. I have the following code: const cintTotalRequests = 25000; var blnNext = true, intRequest = 0; do { if ( blnNext != true ) { continue; ...
SPlatten's user avatar
  • 5,762

1
2 3 4 5
133