Coder Social home page Coder Social logo

Comments (3)

lmammino avatar lmammino commented on July 21, 2024 2

With the current implementation, middlewares do not support promises as return object (which is essentially what happens behind the scenes of async functions).

I think there's an opportunity here to add support for this to allow middy to be even more expressive and simple to use.

I will investigate this option and add few test cases similar to the ones you mentioned here. Feel free to contribute to some proposal if you want.

At a first glance, my current expectation is that we should handle the possibility that a middleware returns a function here. If this happens, we should use attach to the returned promise a .then(runNext) and handler the possible rejection with .catch((err) => done(err)) (or .catch(done) in brief).

But being late at night, that's just me speculating 😛

Thanks for the meaningful reporting though!

@dkatavic what do you think here?

from middy.

coreylight avatar coreylight commented on July 21, 2024

Passing the error to next seems to work, but it might be cool if these were caught without that. 🙂

from middy.

dkatavic avatar dkatavic commented on July 21, 2024

@lmammino I like what you have proposed in PR #51 , async middlewares should be supported out of the box 👍

from middy.

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.