Koa 0.2.0

This release of the Koa framework is short but sweet. If anything this is an indication that our design choices with 0.1.0 were pretty solid, we haven’t come across any road blocks yet in terms of design, so from now on it should be mostly polish, which means if you’d like to start building real projects with Koa you should be safe!

Socket error handling

Koa now handles socket errors for you and relays them to the app’s “error” event for centralized reporting. This is something that you typically have to do yourself with node applications, and if you forget it’s extremely easy to bring down the entire process, but now you won’t have to worry about it!


Jonathan has been working on refactoring some of the shared functionality between Express & Koa into reusable modules. So far we’ve got accepts for content-negotiation, and type-is for request Content-Type assertions.

Refined ctx.throw() signature

This is a tiny change, but previously ctx.throw() accepted ctx.throw(message[, status]) — now you may pass the status first, matching APIs from Express that you may be more used to such as res.send(status, body).

Improved debugging

This update is actually to the koa-compose module, an integral component which composes an array of middleware, and is used in core for app.use().

With the use of the debug module you can enable instrumentation of specified modules — in this case when you use DEBUG=koa-compose the request state is written to stdout before and after each middleware. The number on the left indicates the depth, followed by the middleware name, this makes it very easy to determine which middleware has manipulated the response.

koa-compose debugging


That’s all for now, if you’ve played around with Koa and have suggestions let us know!

    TJ Holowaychuk

    Written by

    Code. Photography. Art.

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade