correct handling of middleware not returning promises