Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
147 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,188
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 ...
Andrew Rendon's user avatar
0 votes
2 answers
88 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
  • 13
0 votes
1 answer
44 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
  • 7,789
-1 votes
1 answer
46 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
42 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
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: { ...
Wernfried Domscheit's user avatar
1 vote
1 answer
87 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
  • 53
0 votes
3 answers
111 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
33 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
39 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
54 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
  • 33
1 vote
3 answers
76 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,511
2 votes
2 answers
163 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
  • 513
1 vote
2 answers
36 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
26 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
63 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
53 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
71 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,678
0 votes
0 answers
22 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
  • 330
0 votes
1 answer
44 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
  • 13.8k
1 vote
1 answer
119 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,375
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....
insanely_sin's user avatar
  • 1,006
-1 votes
1 answer
54 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
0 votes
0 answers
28 views

How do I get a data variable from a Promise function using node js? [duplicate]

This is my code: const execBuffer = require('exec-buffer'); const gifsicle = import('gifsicle'); execBuffer({ input: encoder.out.getData(), bin: 'gifsicle', args: ['--output', execBuffer....
user1154112's user avatar
1 vote
0 answers
140 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,375
0 votes
0 answers
40 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
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 ...
Boo Shorty's user avatar
0 votes
2 answers
86 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
58 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,870
1 vote
1 answer
398 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
66 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
59 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
76 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
87 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,660
-2 votes
1 answer
201 views

I don't understand how to use the async/await in Angular file upload [duplicate]

I am using Angular + Firebase for a simple web app. I have this function: private async uploadFile(id: number, filePath: string, name: string, input: HTMLInputElement) : Promise<string> { ...
Michael's user avatar
  • 351
-3 votes
1 answer
85 views

True Parallelism in Node.js / Javascript? [closed]

const sleep = (ms) => new Promise((resolve) => { setTimeout(resolve, ms) }) async function dbQuery() { const start = Date.now(); await sleep(1000); const end = Date.now(); console.log(...
Sathish's user avatar
  • 2,170
0 votes
0 answers
26 views

Handling Promise based exceptions: foreach vs for.. of [duplicate]

I have a requirement to execute a NodeJs method as shown below (Syntax in TypeScript). The child function checkEntityForPromotion is invoked by the parent function triggerPromotion as shown below. ...
Prabal Rakshit's user avatar
0 votes
0 answers
27 views

Node.js Return value from a function that makes an Http Call [duplicate]

I have a requirement to build a function in Node.js that invokes a synchronous REST API, manipulates the result a little bit and then returns a value. Here is how the function looks like: function ...
Prabal Rakshit's user avatar
0 votes
0 answers
38 views

How can I wait for multiple async operations in Writable stream in Node.js?

Assume I have a writable stream implementation: On each writable chunk, I'm firing an async operation. I don't care about the resolved value. I'm firing the operations in parallel I do want to wait ...
Alon Weissfeld's user avatar
0 votes
2 answers
97 views

Facing difficulty in understanding async await

I'm a beginner. Got confused about async programming after seeing the output of this code async function f1() { console.log('this is f1'); let res = await f3(); console.log('result of f1 from ...
Tony Stark's user avatar
-1 votes
1 answer
420 views

promise with finally block

Anyone master with Promises? I believe there's something subtle here and someone with deep knowledge has an idea. I'm using the finally block with the promise for the first time. The issue is, can you ...
Source's user avatar
  • 309
0 votes
1 answer
58 views

Why this promise never gets resolved?

I'm testing a code that adds promises to a queue and they should be processed in a non-blocking way. I have a code that works as expected but other that doesn't and I don't understand why. Code that ...
Bruno Brito's user avatar
0 votes
0 answers
25 views

Nodejs: Loop Through req.files and Parse PDFs to get Dimensions and write them to the req.files objects

I try to Loop through req.files to get the dimensions of each Page. The Problem is to write back the dimensions into the req.files objects. I need the dimensions at the next function on my route, but ...
RKRdev's user avatar
  • 17
0 votes
0 answers
69 views

Why does my promise resolve earlier than expected?

I have adjusted the post again and added most of the code. I have removed some of the unnecessary code. The point is that I have several items for which I want to call an endpoint one after the other. ...
OliverKhl's user avatar
  • 133
0 votes
4 answers
80 views

Run promises in parallel and return ordered by finish time [duplicate]

I have function fetchData that accepts an integer id and calls promise with random resolve time const promise = (ms) => new Promise((resolve, reject) => { setTimeout(() => { ...
Abobakr's user avatar
  • 43
-1 votes
2 answers
426 views

'util.promisify is not a function' error during Cypress test when trying to run a database query

Unlike all of the 'util.promisify is not a function' threads I've seen, I am not explicitly trying to use the 'util.promisify' function. What I'm trying to do is run database queries during my Cypress ...
Zuno's user avatar
  • 461

1
2 3 4 5
133