Giter Club home page Giter Club logo

Comments (6)

kjvalencik avatar kjvalencik commented on July 3, 2024

Do you mean the JavaScript runtime or the tokio runtime? The JavaScript runtime is single threaded and any time JavaScript is being executed (i.e., when you have access to a Context) it is blocked.

from neon.

Will-Smith11 avatar Will-Smith11 commented on July 3, 2024

Yes i mean javascript. That makes sense, however in regular javascript you can call an async function that loops and the javascript scheduler will move between different pending promises (ie like the loop call future will be moved off main thread to complete other tasks before being moved back on). However that doesnt seem to be the case when im doing calls to neon

from neon.

Will-Smith11 avatar Will-Smith11 commented on July 3, 2024

And example of this would be

Const a = asyncfncall();
Console.log("called async fn");
... other code
Await a;

With regular javascript this works fine. However with neon it doesn't

from neon.

flisky avatar flisky commented on July 3, 2024

just for sure, does the following work for you? @Will-Smith11

console.log("called async fn");
// ... other code
await asyncfncall();

Do you do any blocking in asyncfncall? Could you please give a repo to reproduce this?

from neon.

Will-Smith11 avatar Will-Smith11 commented on July 3, 2024

just for sure, does the following work for you? @Will-Smith11

console.log("called async fn");
// ... other code
await asyncfncall();

Do you do any blocking in asyncfncall? Could you please give a repo to reproduce this?

I was able to resolve this. sorry im a bit of a ts/js noob compared to rust. I was able to fix this by just injecting a promise timeout into my async fn call to encourage the runtime to park the task.

from neon.

kjvalencik avatar kjvalencik commented on July 3, 2024

Glad you figured it out! Resolving a promise usually isn't enough to yield to the event loop because it's a microtask and those get pushed to the front of the queue.

setTimeout, setImmediate, etc, will yield because those push to the back.

from neon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.