#233

ERR_INCOMPLETE_CHUNKED_ENCODING

  1. Issue first appeared on Safari on OSX
  2. Affected only production server
  3. Response from very simple request gave network error ERR_INCOMPLETE_CHUNKED_ENCODING
  4. wat

Symptoms

Simple view to "submit" an object (update "submitted" attribute to a datetime object

 

The View

class ContractCloseOutSubmitView(APIView):
    def post(self, request, contract_id):
        contract = get_object_or_404(
            ContractCloseOut, pk=contract_id)
        if contract.submit():
            return Response({"detail": "Closed successfuly."}, status=200)
        else:
            raise ParseError("Could not submit.")

  1. Angular
  2. nginx
  3. uWSGI
  4. Django
  5. PostgreSQL

The Stack

  1. Only affected production
  2. Could run uWSGI locally and it was fine
  3. Must be nginx

The Clues

Ends up that nginx's buffer loses it's shit when you don't read the response body of a POST.

 

You can either force the buffer to read the entire request (which can be inefficient). Or.....

The Solution

class ContractCloseOutSubmitView(APIView):
    def post(self, request, contract_id):
        data = request.data #touchie touchie
        contract = get_object_or_404(
            ContractCloseOut, pk=contract_id)
        if contract.submit():
            return Response({"detail": "Closed successfuly."}, status=200)
        else:
            raise ParseError("Could not submit.")

wat

Made with Slides.com