1,190 questions
0
votes
0
answers
35
views
How to handle an error thrown by an asynchronous function? [duplicate]
This is not a duplicate to this question since it discusses rejecting promises. This is about errors that are thrown. It is also worth mentioning that I can't modify the behavior of the mpv....
0
votes
1
answer
190
views
How "for await" loop in Async "queue" could invoke "dequeue" before "enqueue"? It returns new Promise() before it put into queue
I am newbie to Javascript and been reading the David's Flanagan Guide to have general overview.
This code snippet made me confused. I could not realise how the Promise in loop is 'dequeued' before ...
0
votes
1
answer
209
views
(TS 2556) Why am I recieving a type error on a spread argument that has already been explicitly typed and passed as a rest parameter?
function debouncePromise<TParams extends Array<unknown>, TRes>(
fn: (a: TParams) => Promise<TRes>,
time: number,
) {
let timerId: ReturnType<typeof setTimeout> | ...
0
votes
0
answers
63
views
Why does async.queue randomly fail sometimes?
I have written a routine for queueing a set of http requests so that they happen in sequence instead of concurrently. I am using this async library: https://caolan.github.io/async/v3/. This is ...
-1
votes
1
answer
74
views
News.js:16 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'state')
I am getting error of** "News.js:16 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'state')"** when ever i am clicking on next button.
error occur in URL of ...
0
votes
2
answers
85
views
how JS program knows the time in setTimeout inside a function? [duplicate]
const p1 = new Promise((resolve,reject) => {
setTimeout(()=>{
resolve("xxx");
}, 5000)
});
const p2 = new Promise((resolve,reject) => {
setTimeout(()=>{
resolve("xx");
}, ...
1
vote
1
answer
38
views
React Native App only setting to state on second load
I am currently working on the capstone for my course, but I have to use multiple async functions. I need to use AsyncStorage, SQLite storage, and fetching from a REST API. The issue I am encountering ...
0
votes
2
answers
219
views
How to insert a simple delay into javascript
So I want to do some web scraping, using AppleScript to run javascript code on a webpage. I have the following code: (edited to remove proprietary data)
function inputPunch(date_string) {
// ...
0
votes
1
answer
97
views
send a file from a <input> to google drive, but not directly (I need to do some data treatment first using GAS)
I have a huge form with all kind of inputs that I need to do data treatment and then register directly on multiples spreadsheets.
The first part of getting the values and sending it to the ...
0
votes
0
answers
17
views
Sending request with data from other request
I have an User context provider where I want to store functions that validate and refresh his JWT token before every request.
Here is template of my code
const UserContext = createContext({})
const ...
1
vote
2
answers
2k
views
Load Script With Async Functions Before Any Element
I want to verify the user credentials before any page of my site load, so I put an script in the top of each of my HTML document. But this script in particularly has Async functions (because it sends ...
0
votes
0
answers
28
views
async.eachSeries gives error callback is not defined
async.eachSeries([1,2,3], async(item, callback) => {
//await delay(6000);
console.log(item);
callback(null);
}, function(done) {
if(done == null){
}
});
...
1
vote
0
answers
107
views
Append file's content to the new file is not working
I have a folder with 4 files with CSS styles.
Using Node.js modules tried to create a new file 'bundle.css' and append content of these 4 files with style (css).
But the code instead of styles, return:...
0
votes
1
answer
166
views
Node JS Async function not working as expected
I am using NodeJS 18 version, and I am trying to paginate the dynamo DB results using the async function, but it is not giving me any results. My dynamo DB table has the data.
I am using the dynamo db ...
0
votes
1
answer
1k
views
How to sleep component with useEffect
I am trying to implement sorting algorithms and build react app to display how unsorted array is changing with each iteration.
To make it visible, app has to stop for some time after every iteration ...
0
votes
0
answers
28
views
mongodb client nodejs check if database exist else run "async.each" to create collection
Hello I got a problem that mongodb client try to check if collection exist or not
Here is the connect function:
const { MongoClient } = require("mongodb");
const async = require("async&...
1
vote
1
answer
35
views
Reference property from Firestore is always undefined
I have a query that outside the emulator is always returning a document reference property as undefined.
UPDATE: The issue is happening when running from the browser.
Of course, I checked the ...
-1
votes
2
answers
83
views
How to use my API data I gathered through a GET request into a separate function
I am tasked with fetching data from an API and storing that data on a card for the game jeopardy I am creating. I am able to successfully fetch my data question from my api but am having a hard time ...
1
vote
0
answers
74
views
Firebase async fuzzy search fail with crash
So Im building sort of 'fuzzy_search' tool that search with selective precision. Divide string on chunks and if some of them are similar to firebase entries it return array of suggested items.
And it ...
0
votes
1
answer
55
views
Cant access main parents callback function inside mongo query | cb is not a function
I am working with mongodb in sails js. we are using async.auto from async.js.
I am creating a new mongo connection for few reasons and firing find query to get the data, after retrieving data from db ...
0
votes
1
answer
475
views
Is there a way to detect if the method inside the decorator is async or not - JS [duplicate]
I looking for a way to detect if my function inside the decorator is async or not.
function catchError(target: any, propertyName: string, descriptor: PropertyDescriptor) {
const method = ...
-2
votes
1
answer
106
views
Javascript addEventListener is Not being Executed or is There an await Problem
I have a Chrome extension with the following js code in the initial HTML.
(async() => {
console.log("Starting wrapper");
await document.getElementById("start")....
0
votes
1
answer
200
views
Flutter warning message "Do not use BuildContexts across async gaps" causing application failure. I am not using stateless widget
below is the complete code, I have added the issue description before each line when the issue occurred:
class AuthService {
//sign up user
void signUpUser({
required BuildContext context,
...
0
votes
1
answer
42
views
Node.js write object propertys in same time via socket.io
In Node.js, can it happen that when different properties of a global object are written at the same time (with a socket.io request), one of the properties retains its original value?
`
var rooms = {
...
0
votes
0
answers
106
views
NodeJs parallel request in a loop too slow
so I have this feature that I am working on that takes an object (Over 10k items) picks an item from this object, sends it to an api, which process it then give a response, then proceeds to the next ...
0
votes
1
answer
203
views
Async Queue Library, Pass variables to callback
I'm using the async library to create a queue.
My code for my queue looks something like this.
const async = require('async');
const db = require('../models');
const logger = require('../logger');
var ...
0
votes
0
answers
23
views
Javascript, How to call event listener to not yet created DOM element [duplicate]
strong textI am trying to add plus and minus to input form.
the input is only created in js script so it doesnt exist on DOM yet when calling the event.
I tried async function but that didn't really ...
0
votes
1
answer
287
views
Node.js on multi-core machines for file I/O operations
I'm a bit confused because all the examples I read about Node cluster module only seem to apply to webservers and concurrent requests. Otherwise to CPU intensive application it is recommended to use ...
0
votes
1
answer
2k
views
Type 'Promise<void>' is not assignable to type 'void | Promise<OptionsOrGroups<Place, GroupBase<Place>>>'
I'm using a React library called Leaflet consuming data from Mapbox API to create a map in may delivery services application. I created a method called loadOptions to select one specific address ...
0
votes
1
answer
75
views
Problem with converting currying form promise chain
We have a utility function that wrappers axios http call; currently it's written in currying form of chained promise as below:
request<T>(request: AxiosRequestConfig, x: number, y: string, z: ...
1
vote
1
answer
57
views
How to handle asynchronous code and pass it down to props?
So I'm working on an app, and in the app there's a component that handles a bunch of data mutations. I'll explain it in pseudocode for brevity and link the full code sample below.
function ({ API_DATA ...
0
votes
2
answers
4k
views
How to use async/await on event handlers on buttons in JavaScript?
I'm new too JavaScript and am having trouble with async. I have a webpage with two buttons, If the yes button is pressed it will do some code and if the no button is pressed it will do different code ...
0
votes
1
answer
121
views
how to correctly return data from async function node js, jest error
I have a function something like that:
async function example(){
let data = await another_function();
var ws = fs.createWriteStream('path');
let jsonData = [{'id':'1234', 'name': 'Alex'}];
fastcsv
...
0
votes
1
answer
72
views
Why using asyncronus function if then you await their response?
Why we using async function if then we use await for waiting their response, in this case what's the difference between a syncronus function?
1
vote
0
answers
68
views
i have converted excel data into json using npm library convert-excel-to-json but now I have to use async.eachSeries to insert data into mongoDb ,how?
/* I have to use async.eachSeries to insert and validate duplicate
data but the library is returning array of objects ,How can I do
it Can anyone help
*/
app.post("/",upload.single(&...
1
vote
1
answer
2k
views
Using Await While Looping a Map Object
How can you iterate over each value in a Map, in manner where await will be honored in the body of that loop?
2
votes
1
answer
531
views
JavaScript quiz of printing sequence with combination of promise.then and async function
I'm confused about the order of executing promise.then with async function. The result of that quiz that shows on the console is: 1, a, 2, b, c, d, 3, e.
I'm wondering:
Why 3 just inserts to between ...
2
votes
0
answers
127
views
Typescript support for async.auto in async.js library
How do we strongly type each of the async auto tasks? let's say get_data returns a number and email_link returns a string and I finally want to return the email_link task.
I am unable to figure out ...
2
votes
1
answer
656
views
Using Angular Observable : cannot read properties of undefined (reading 'foo')
I'm having a service as follow:
public getDoseVignettes() : Observable<DoseVignetteApi> {
return this.apollo.watchQuery<Query>({
query: this.VIGNETTE
}).valueChanges
....
-1
votes
1
answer
45
views
Node Express - Database is created too late causing error
My problem is with creating a database. It is created too late and causes problems with further queries. I tried to use async and await but it seems it doesn't solve the problem.
async function ...
0
votes
0
answers
1k
views
Async/Await promise being called twice
I'm trying to check if a connection exists after attempting to delete it. At this point the connection has already been deleted and it is now about to start checking once every second for 10 seconds. ...
0
votes
3
answers
3k
views
getting SyntaxError: await is only valid in async functions and the top level bodies of modules while working through the discord.js guide [closed]
I'm working through the guide for discord.js but when I try and set permissions for the slash commands I keep getting the SyntaxError: await is only valid in async functions and the top level bodies ...
2
votes
0
answers
148
views
Unhandled promise rejection when executing file using node
I am trying to run a cron job on Heroku which runs daily. The node version this Heroku server/project uses is v9.4. I am also using the async package v2.6.1
When I run the file using node: node dist/...
0
votes
1
answer
69
views
Async JS validation issues for html textarea
I'm trying to replicate the code in this article:
https://depth-first.com/articles/2020/08/24/smiles-validation-in-the-browser/
What I'm trying to do different is that I'm using a textarea instead of ...
1
vote
0
answers
361
views
Callback was already called Async Nodejs
I'm receiving this error with the Coalan Async library.
Error: (node:2172) UnhandledPromiseRejectionWarning: Error: Callback was already called.
Here is my code:
const updateOrCreateTrips = (trips, ...
0
votes
2
answers
2k
views
Make JavaScript wait until websocket receives a reply
So as the title says, I'm playing around with websockets. So far all good, except for the fact that I can't make the page wait until we get a reponse. Now, I do actually have a good reason to do this; ...
0
votes
1
answer
171
views
how to handle assynchronous SQL query execution in node.js
I am new to node.js and mysql, I asked a similar question before, but my whole server is chaos, so I took sometime improving it. But I got back to the asynchronous problem:
How can I handle ...
0
votes
0
answers
30
views
how to handle synchronous databse query in node.js
I am new to node.js, and I am starting with login and signUp implementation, and I have just found that my database Query of MySQL failed to execute in sequence. So what I do is to find does username ...
2
votes
1
answer
221
views
Function fails to fully build JSON under load
I'm working on an OSS project called pSConfig Web Admin (PWA). The biggest problem we're having is that under load, the generated JSON will occasionally be delivered incomplete (as documented in this ...
2
votes
1
answer
903
views
node: async.parallelLimit with async functions and await
I am trying to execute some (several thousand) jobs in "parallel".
The problem is each job can potentially contains a request to an external server, requires several MB memory. So just ...