4

Anyone ever seen the behavior with async methods and promises where at the end of what should finish the await in the calling code the function never progresses past the await even though it returned ?

Comments
  • 0
    Is the callee returning a promise?
  • 0
    @galileopy the callee is an async event handler attached to an express endpoint
  • 0
    @galileopy well technically the callee returns a promise
    The caller is an async function being awaited by the express async event handler
  • 0
    @galileopy both layers are doing a await
  • 0
  • 0
  • 0
  • 0
    @killames why do you have an async express handler? Express is explicitly a continuation passing stack.
  • 0
    @galileopy if I’m remembering
    It’s the way it was laid out in example code and it’s the only way I can use await
  • 0
    @killames well, if something gets stuck in await it can be.
    1. An uncaught exception. Passing straight to the catch
    2. The callee is returning a promise that never resolves, say you have 2 promises in callee one resolves the other didn't, and callee is returning the one that didn't.

    And that's pretty much it.
  • 0
    Also, example code from the webs is full of bugs, better to understand the concept than to try modify an example written by a rando.
  • 0
    @galileopy I stepped through the code but I’ll do so again I suppose
  • 0
    @galileopy well I hadn’t worked with async crap previously

    This code works until the server bug says an asset doesn’t exist once too often heh
  • 0
    @killames ohhh. A bad breakpoint in debugging can also be the reason 🤣
  • 0
    @galileopy how ?
  • 0
    @killames you asked how can code get stuck on an await call. Another possible reason is a breakpoint. That one is the funniest one, because it can only happen when you're debugging.
  • 0
    @galileopy well that’s not where it was always happening
    Personally I think promise code is kind of worthless

    Async should be done on threads
  • 0
    @galileopy I just don’t see a lot of reasons yet to do async the way node does
  • 0
    @galileopy it makes the code messy
  • 0
    god i hate node js and its lack of defined threading ! it makes the code so goddamned messy and you can't even expect that event handlers will return on the same thread so you end up with spaghetti code from hell if you use async functionality as it appears !
  • 0
    sounds like you're trying to make js behave like a real programming language. tisk tisk poor you.
  • 0
    It's odd how you guys can get tangled with Node.js it is the most beautiful language used in the mainstream. The thing I love most about it, is that you can use powerful functional patterns without a compiler or typesystem code-blocking you.
  • 1
    @galileopy to wrote spaghetti code unless you force everything to be synchronous or write everything like a processing queue
  • 0
    @killames Yo don't need to write everything to be sync. Or write spaghetti. Nose surely has a learning curve, that is, if you want to write good Node code.
  • 1
    @galileopy yes but this seems like a failure which really it kind of is

    Like I know how I might have go speed a certain part of my code

    Which would be to add a status field to a list of global records that indicate which of several timer calls should pick it up and do something to it

    That’s ridiculous

    When I could write one thread and just spawn several copies that report their progress and one controller thread that either cancels a frozen one or starts a new one when one finishes
  • 0
    @killames You can do that with worker threads.

    https://nodejs.org/docs/...
  • 1
    @galileopy I’d still have to manually wrap things in promises or specifically call sync methods is the problem so it just doesn’t seem like that is really the answer at this point lol

    I mean holy shit everything requires a callback or uses a promise so it’s all async by default and they have worker threads lol what a ducking mess of a language lol
  • 1
    @galileopy the answer seems to be to design globally exposed datasets and the like and multiple timer events that do what I said which would like simply the code considerably because you could just use the stupid callbacks and all the asyncs heh
  • 0
    Ohh, I didn't realize you just wanted to troll. Be my guest, yeah, node sucks. Java FTW. C# rocks. Who needs single threaded event loops anyways.
  • 1
    @galileopy not trolling
    Node is a terrible idea
    It’s a terrible implementation
    C# isn’t a bad language
    But I’ve been writing things in a node and I’m discovering all its little gotchas

    It’s not a complete development kit
    It’s a niche development kit
    It has specific uses and those uses so far as I can tell are mostly to perform simple quick tasks and return a result

    What I’m writing now could have been accomplished much quicker in other languages so I’m discovering it’s quirks rather rapidly

    And then there is the reliance on 3rd party modules which either function
    Strangely or don’t function at all and we had this conversation already
Add Comment