Skip to content

Function app freezes when receiving POST request larger than about 2 million characters (locally) on python 3.13 #1809

@BenKGIT

Description

@BenKGIT

Setup

When I run my Azure function app locally via func start in PowerShell I try to send a POST request to an endpoint I created. The POST request simply consists of one key and its value with more than about 2 million random alphanumeric characters.

function_app.py

import azure.functions as func
import json
import logging

app = func.FunctionApp()

@app.route("test",methods=["POST"])
def test(req: func.HttpRequest) -> func.HttpResponse:
    logging.info("Processing request at /test endpoint.")

    try:
        return func.HttpResponse(
            json.dumps("Received document successfully."),
            status_code=200,
            mimetype="application/json"
        )
    
    except ValueError:
        return func.HttpResponse(
            "Invalid JSON payload.",
            status_code=400
        )
    except Exception as e:
        logging.error(f"Unexpected error: {e}")
        return func.HttpResponse(
            "Internal server error.",
            status_code=500
        )

test.py

import requests
import random
import string

rnd = ''.join(random.choices(string.ascii_letters + string.digits, k=2_500_000))
print(len(rnd))

data = {"base64_document": rnd}

response = requests.post("http://localhost:7071/api/test", json=data)
print(response.status_code)

Problem

Now when I run func start and after that python test.py I get the output in the log

'local.settings.json' found in root directory (REDACTED).
Resolving worker runtime to 'python'.
Found Python version 3.13.9 (python3).
Azure Functions Core Tools
Core Tools Version:       4.5.0+e74aae22c9630777c9f58354f290a6e214218546 (64-bit)
Function Runtime Version: 4.1044.400.25520
[2025-11-30T06:02:59.501Z] Worker process started and initialized.
Functions:
        test: [POST] http://localhost:7071/api/test
For detailed output, run func with --verbose flag.
[2025-11-30T06:03:17.837Z] Worker process started and initialized.
[2025-11-30T06:03:23.816Z] Executing 'Functions.test' (Reason='This function was programmatically called via the host APIs.', Id=ca3951a9-cb7a-41ea-9267-edb2367ba261)
[2025-11-30T06:13:23.834Z] Timeout value of 00:10:00 exceeded by function 'Functions.test' (Id: 'ca3951a9-cb7a-41ea-9267-edb2367ba261'). Initiating cancellation.
[2025-11-30T06:13:23.843Z] Executed 'Functions.test' (Failed, Id=ca3951a9-cb7a-41ea-9267-edb2367ba261, Duration=600076ms)
[2025-11-30T06:13:23.844Z] Microsoft.Azure.WebJobs.Host: Timeout value of 00:10:00 was exceeded by function: Functions.test.

but nothing after that. It runs for a 10 minutes (the timeout duration I set) and eventually gives me a 500 or 504.

I have tried all configurations for my host.json and local.settings.json I could find and change them to the maximum values but that did not fix my problem.

This problem should be easily reproducible though because the problem also occurs with the default settings and the provided code when running on python version 3.13. Does anyone have an idea how to fix this without changing the request data type (like multipart) or chunking?

I tested out different python versions and it seems to be an issue exclusive to python 3.13 (I tested 3.13.9, 3.13.8, 3,12.12, 3.10.11). 3.10 and 3.12 worked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions