koajs/compose

compose 3.1.0 may enter an infinite loop

zbinlin opened this issue · 2 comments

Test case:

const compose = require("koa-compose");

compose([
  function A(ctx, next) {
    console.log("A called");
    return next();
  },
])({}, function B(ctx, next) {
  console.log("B called");
  return next(); // if call next function here, it will enter an infinite loop
}).then(() => console.log("done"), err => console.error(err));

The fix is simple, but do we want to make a minor breaking change for that? I think we do, as I can't see this current behavior being used in production. @jonathanong Thoughts?

well it's a bug, but it's not a priority. if someone can think of a fix, that would be great!