thiagobustamante / typescript-rest

This is a lightweight annotation-based expressjs extension for typescript.
MIT License
523 stars 110 forks source link

Route calls next() after sending response #166

Open beaverusiv opened 2 years ago

beaverusiv commented 2 years ago
"express": "^4.17.2",
"typescript-rest": "^3.0.4",

I have a route in a service:

  @GET
  @Path("/")
  @PreProcessor(restAuthorise(all))
  getBulkConflictsForm(@HeaderParam("content-type") contentType = "") {
    return this.presenter.makeBulkConflictsForm(contentType === "application/json");
  }

As you can see it returns a value; a JSON representation of a form. So far, so good, when requesting the endpoint it returns 200 OK and the correct JSON. However:

  typescript-rest:service-invoker:runtime Sending a json value: {"links":[{"rel":"self","href":"https://proxy:4433/animal-genome/bulk-conflicts"},{"rel":"up","href":"https://proxy:4433/"}],"items":[{"id":"animalIds","name":"animalIds","description":"Array of animal Ids","type":"number"}]} +0ms
  express:router <anonymous>  : /animal-genome/bulk-conflicts +5ms
  express:router <anonymous>  : /animal-genome/bulk-conflicts +0ms
  express:router <anonymous>  : /animal-genome/bulk-conflicts +0ms
  express:router <anonymous>  : /animal-genome/bulk-conflicts +1ms
  finalhandler default 404 +3m
  finalhandler cannot 404 after headers sent +0ms

After sending the response the code looks to still call next(). As far as I can tell it shouldn't because I've returned a value from the service call, right? It should res.send() and be done.