socket.io control execution order with nested async and awaitHttpClient.GetAsync(…) never returns when using await/asyncasync/await - when to return a Task vs void?Using async/await for multiple tasksHow and when to use ‘async’ and ‘await’ContextBoundObject with Async/AwaitConfusion with async/await web calls in orderUsing async/await with a forEach loopAsync/Await Mongoose doesn't always run correctlyJavascript async await not waiting for mongoose awaitHow to execute socket.io endpoints sychronously
What are the purposes of autoencoders?
copy and scale one figure (wheel)
Has any country ever had 2 former presidents in jail simultaneously?
Loading commands from file
What should you do if you miss a job interview (deliberately)?
Start making guitar arrangements
What is Cash Advance APR?
Why Shazam when there is already Superman?
Create all possible words using a set or letters
Why is so much work done on numerical verification of the Riemann Hypothesis?
When were female captains banned from Starfleet?
What is this called? Old film camera viewer?
What does chmod -u do?
How to explain what's wrong with this application of the chain rule?
What if a revenant (monster) gains fire resistance?
What was this official D&D 3.5e Lovecraft-flavored rulebook?
If a character has darkvision, can they see through an area of nonmagical darkness filled with lightly obscuring gas?
Count the occurrence of each unique word in the file
Why electric field inside a cavity of a non-conducting sphere not zero?
The screen of my macbook suddenly broken down how can I do to recover
Did arcade monitors have same pixel aspect ratio as TV sets?
How to bake one texture for one mesh with multiple textures blender 2.8
Can I sign legal documents with a smiley face?
What was the exact wording from Ivanhoe of this advice on how to free yourself from slavery?
socket.io control execution order with nested async and await
HttpClient.GetAsync(…) never returns when using await/asyncasync/await - when to return a Task vs void?Using async/await for multiple tasksHow and when to use ‘async’ and ‘await’ContextBoundObject with Async/AwaitConfusion with async/await web calls in orderUsing async/await with a forEach loopAsync/Await Mongoose doesn't always run correctlyJavascript async await not waiting for mongoose awaitHow to execute socket.io endpoints sychronously
In my app, I have multiple users submitting data "at once" via a socket.event.
Because I need to know if every user has submitted their data successfully, I try to indentify the first and last entry.
For that, I call an async function on the event, which itself includes "await".
Basically, the function looks for a value in the database and then does something depending on whether it exists or not.
Because of that, I need the function block (with its awaits) to be fully executed before the next instance of the function is called.
However, what I found is that the as soon as I call await inside the function, the next instance of said function starts executing, which obviously messes everything up.
socket.on("entries", async entries =>
const firstEntry = await match.noEntries(mid);
if (firstEntry)
//do sth
await match.submitEntries(mid, socket.pid, entries);
);
//FUNCTION
noEntries: async (mid) =>
const entries = await database.query("...");
return (entries.length == 0);
Is there any way I can prevent the next instance of the function to be executed before it's predecessor has finished?
Thanks in advance!
javascript node.js asynchronous socket.io async-await
add a comment |
In my app, I have multiple users submitting data "at once" via a socket.event.
Because I need to know if every user has submitted their data successfully, I try to indentify the first and last entry.
For that, I call an async function on the event, which itself includes "await".
Basically, the function looks for a value in the database and then does something depending on whether it exists or not.
Because of that, I need the function block (with its awaits) to be fully executed before the next instance of the function is called.
However, what I found is that the as soon as I call await inside the function, the next instance of said function starts executing, which obviously messes everything up.
socket.on("entries", async entries =>
const firstEntry = await match.noEntries(mid);
if (firstEntry)
//do sth
await match.submitEntries(mid, socket.pid, entries);
);
//FUNCTION
noEntries: async (mid) =>
const entries = await database.query("...");
return (entries.length == 0);
Is there any way I can prevent the next instance of the function to be executed before it's predecessor has finished?
Thanks in advance!
javascript node.js asynchronous socket.io async-await
let me ask to see if I got your question. So you basically want to execute every callback from your "entries" even synchronously between them (like one after another), although each callback are asynchronous by itself?
– Gonzalo.-
2 days ago
yes, that's on point
– Hylaze
yesterday
add a comment |
In my app, I have multiple users submitting data "at once" via a socket.event.
Because I need to know if every user has submitted their data successfully, I try to indentify the first and last entry.
For that, I call an async function on the event, which itself includes "await".
Basically, the function looks for a value in the database and then does something depending on whether it exists or not.
Because of that, I need the function block (with its awaits) to be fully executed before the next instance of the function is called.
However, what I found is that the as soon as I call await inside the function, the next instance of said function starts executing, which obviously messes everything up.
socket.on("entries", async entries =>
const firstEntry = await match.noEntries(mid);
if (firstEntry)
//do sth
await match.submitEntries(mid, socket.pid, entries);
);
//FUNCTION
noEntries: async (mid) =>
const entries = await database.query("...");
return (entries.length == 0);
Is there any way I can prevent the next instance of the function to be executed before it's predecessor has finished?
Thanks in advance!
javascript node.js asynchronous socket.io async-await
In my app, I have multiple users submitting data "at once" via a socket.event.
Because I need to know if every user has submitted their data successfully, I try to indentify the first and last entry.
For that, I call an async function on the event, which itself includes "await".
Basically, the function looks for a value in the database and then does something depending on whether it exists or not.
Because of that, I need the function block (with its awaits) to be fully executed before the next instance of the function is called.
However, what I found is that the as soon as I call await inside the function, the next instance of said function starts executing, which obviously messes everything up.
socket.on("entries", async entries =>
const firstEntry = await match.noEntries(mid);
if (firstEntry)
//do sth
await match.submitEntries(mid, socket.pid, entries);
);
//FUNCTION
noEntries: async (mid) =>
const entries = await database.query("...");
return (entries.length == 0);
Is there any way I can prevent the next instance of the function to be executed before it's predecessor has finished?
Thanks in advance!
javascript node.js asynchronous socket.io async-await
javascript node.js asynchronous socket.io async-await
asked 2 days ago
HylazeHylaze
62
62
let me ask to see if I got your question. So you basically want to execute every callback from your "entries" even synchronously between them (like one after another), although each callback are asynchronous by itself?
– Gonzalo.-
2 days ago
yes, that's on point
– Hylaze
yesterday
add a comment |
let me ask to see if I got your question. So you basically want to execute every callback from your "entries" even synchronously between them (like one after another), although each callback are asynchronous by itself?
– Gonzalo.-
2 days ago
yes, that's on point
– Hylaze
yesterday
let me ask to see if I got your question. So you basically want to execute every callback from your "entries" even synchronously between them (like one after another), although each callback are asynchronous by itself?
– Gonzalo.-
2 days ago
let me ask to see if I got your question. So you basically want to execute every callback from your "entries" even synchronously between them (like one after another), although each callback are asynchronous by itself?
– Gonzalo.-
2 days ago
yes, that's on point
– Hylaze
yesterday
yes, that's on point
– Hylaze
yesterday
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281391%2fsocket-io-control-execution-order-with-nested-async-and-await%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281391%2fsocket-io-control-execution-order-with-nested-async-and-await%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
let me ask to see if I got your question. So you basically want to execute every callback from your "entries" even synchronously between them (like one after another), although each callback are asynchronous by itself?
– Gonzalo.-
2 days ago
yes, that's on point
– Hylaze
yesterday