Git Product home page Git Product logo

Comments (5)

rotu avatar rotu commented on August 28, 2024 1

I figured the immediate resolution was intended, since that's also the behavior for when delay is 0.

Also, the createTimeout returns either null, a non-resolving Promise, a {start, clear} object, or an inscrutable wrapper promise. And it has an argument called signal which seems to be given an AbortController, not an AbortSignal?

This code is an impressive fractal of WTF!

from agent.

hashtagchris avatar hashtagchris commented on August 28, 2024 1

Thanks @rotu! Core feedback addressed.

First array element is now thrown:

agent/lib/agents.js

Lines 149 to 151 in d3187c4

once(socket, 'error', { signal }).then((err) => {
throw err[0]
}),

util.js has been removed, and I couldn't find any non-resolving Promises.

from agent.

lukekarrys avatar lukekarrys commented on August 28, 2024

Due to the way once works, this expression throws an Array containing a single Error instead of the probably intended Error.

This is a mistake and should be fixed. Nice catch!

This code creates a non-resolving promise (maybe instead of an immediately-resolving Promise?).

This could use a comment, or a refactor. This code path is only used in a Promise.race so passing a non-resolving promise is done on purpose if no timeout is passed in. Using an immediately resolving promise would make it immediately resolve the Promise.race which is not what is wanted.

from agent.

wraithgar avatar wraithgar commented on August 28, 2024

If the promise never resolves, what is it racing?

from agent.

wraithgar avatar wraithgar commented on August 28, 2024

oh ... if no timeout is passed. We should just return the original promise then.

ETA I think a bit of a refactor is in order here too. These are good catches!

from agent.

Related Issues (12)

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.