Skip to content

Unexpected Change in res.is_completed() Behavior in Crow 1.2.1.2 #1059

@MESURF88

Description

@MESURF88

In upgrading to Crow version 1.2.1.2, we encountered an unexpected change in how res.is_completed() behaves during request handling.

Previously, our API logic used res.is_completed() to determine if the response had already been finalized. This allowed us to short-circuit execution paths and avoid duplicate response handling in specific routes. However, after updating to 1.2.1.2, these same endpoints began consistently returning 400 Bad Request responses in cases where we rely on res.is_completed() to decide early exit conditions.

Upon investigation, we traced the issue to a change introduced in commit #799. In this commit, response writing was made synchronous, and the completed_ flag appears to be reset (cleared) after res.end() is called. As a result, calls to res.is_completed() in our logic immediately following res.end() now return false instead of true, breaking our previous flow control.

We’ve temporarily reverted to Crow 1.2 to restore the expected behavior.

Could you clarify the intended usage and contract of res.is_completed() going forward, particularly in light of this commit?
Is the response expected to appear "incomplete" until the write fully finishes now?

Thanks in advance

example of our flow control:
`
void Authorize(const crow::request& req, crow::response& res)
{

  ...

  res = crow::response(crow::status::OK, "okay");
  res.end();
  return;
}

`

`
this->Authorize(req, res);

      if (res.is_completed()) return;

      res = crow::response(crow::status::BAD_REQUEST);
      res.end();
      return;

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdiscussionThe viability / implementation of the issue is up for debate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions