Skip to content

Http in Post with file uploads crashes node-red with large files #5248

Closed

Description

@Hugobox

Current Behavior

I have encountered a crash on a flow that processes media files and managed to reproduce using only the http in node connected to a debug node. I then use Postman to send a POST to this endpoint with a large file (230mb) in form-data. The result is a nodejs crash.

I also tried adding in settings.js: apiMaxLength: '4000mb',
but it doesn't make a difference, still crashes consistently.

Here's the crash log:

11 Aug 14:15:41 - [info] Started modified nodes

<--- Last few GCs --->
= [33132:000001BB913C1000] 364344 ms: Mark-Compact 212.0 (228.2) -> 187.1 (204.3) MB, pooled: 1 MB, 5.98 / 0.00 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 334 ms) (average mu = 0.981, current mu =[33132:000001BB913C1000] 365794 ms: Mark-Compact 475.1 (492.3) -> 307.1 (324.3) MB, pooled: 1 MB, 16.05 / 0.00 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 990 ms) (average mu = 0.987, current mu

<--- JS stacktrace --->

FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

1: 00007FF7BF2E542D node::SetCppgcReference+17693
2: 00007FF7BF248248 SSL_get_quiet_shutdown+102712
3: 00007FF7BFDCED41 v8::Isolate::ReportExternalAllocationLimitReached+65
4: 00007FF7BFDBB9C6 v8::Function::Experimental_IsNopFunction+2870
5: 00007FF7BFC08B10 v8::internal::StrongRootAllocatorBase::StrongRootAllocatorBase+31456
6: 00007FF7BF9E2BB9 v8::MemorySpan<std::basic_string_view<char,std::char_traits > const >::end+195625
7: 00007FF7BF9D4885 v8::MemorySpan<std::basic_string_view<char,std::char_traits > const >::end+137461
8: 00007FF7BFABB16E v8::MemorySpan<std::basic_string_view<char,std::char_traits > const >::end+1081822
9: 00007FF7BFAB5732 v8::MemorySpan<std::basic_string_view<char,std::char_traits > const >::end+1058722
10: 00007FF7BFA533F1 v8::MemorySpan<std::basic_string_view<char,std::char_traits > const >::end+656481
11: 00007FF7BF9DD9BD v8::MemorySpan<std::basic_string_view<char,std::char_traits > const >::end+174637
12: 00007FF7BF9F0194 v8::MemorySpan<std::basic_string_view<char,std::char_traits > const >::end+250372
13: 00007FF7BF8F0E69 v8::base::AddressSpaceReservation::AddressSpaceReservation+302697
14: 00007FF7BFB8D61D v8::Platform::SystemClockTimeMillis+149885
15: 00007FF7BFE8A0CE v8::PropertyDescriptor::writable+725950
16: 00007FF74032F837

Expected Behavior

No response

Steps To Reproduce

1 - import flow.
2 - use any means to do an http POST with file attachment, I'm using Postman but also tried with a custom web app

Image

3 - Notice crash

Example flow

[
    {
        "id": "bcfc9b26534bd5b9",
        "type": "http in",
        "z": "665a5b6008138007",
        "name": "",
        "url": "/test",
        "method": "post",
        "upload": true,
        "skipBodyParsing": false,
        "swaggerDoc": "",
        "x": 500,
        "y": 120,
        "wires": [
            [
                "5501a443572560b6"
            ]
        ]
    },
    {
        "id": "5501a443572560b6",
        "type": "debug",
        "z": "665a5b6008138007",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 750,
        "y": 120,
        "wires": []
    }
]

Environment

  • Node-RED version: 4.1.0
  • Node.js version: 22.17.0
  • npm version: 10.9.2
  • Platform/OS: Windows
  • Browser: Chrome: 139.0.7258.66

Activity

  1. hardillb commented on Aug 11, 2025

    @hardillb
    Member

    The crash is because the NodeJS runtime has run out of memory. Changing the size of the upload limit won't change how much memory the system need to process the incoming file (probably at least double the size of the file).

    You only option is to run Node-RED on a machine with more memory and try and adjust the NodeJS heap size to try and help.

  2. Hugobox commented on Aug 11, 2025

    @Hugobox
    ContributorAuthor

    I currently have 5.4Gb available on my laptop and node-red crashes, so that doesn't look like the culprit. I'll try to adjust the NodeJS heap size and report back. Thanks!

  3. hardillb commented on Aug 11, 2025

    @hardillb
    Member

    P.s. you also really need a http-response node in your flow, or the http requests will stay open for a long time and keep the file payload in memory even longer than needed.

  4. Hugobox commented on Aug 11, 2025

    @Hugobox
    ContributorAuthor

    I initially had an http response but removed it to simplify the test flow even more and to ensure that there is no funny business with the http-in node having two outputs and cloning the message. Even with an http response and starting node-red with: node --max-old-space-size=4096 node_modules/node-red/red.js -v -u .
    it still crashes.

  5. Hugobox commented on Aug 11, 2025

    @Hugobox
    ContributorAuthor

    Also as a side note, even with the apiMaxLength: '10mb', I can send it files that are 60Mb but that's another story....

  6. hardillb commented on Aug 11, 2025

    @hardillb
    Member

    Does it work if you remove the debug node and just have the http-response? The debug node does a lot of work to try and convert things to readable strings

  7. Hugobox commented on Aug 11, 2025

    @Hugobox
    ContributorAuthor

    Good call! It doesn't crash when I remove the debug node and only have the http-in to http response. Not sure If its intended, but the response I get in Postman is only the json part ({"test": "wawa"}) the file is not part of the response, but at least it doesn't crash.

  8. Hugobox commented on Aug 11, 2025

    @Hugobox
    ContributorAuthor

    If i put a function in between the http-in and the http response with:
    if (msg.req.files){
    node.warn("file is detected")
    }
    return msg;
    it doesn't crash and debug shows file is detected.

    but if I change the function to:
    if (msg.req.files){
    node.warn(msg.req.files)
    }
    return msg;
    then it crashes.

  9. hardillb commented on Aug 11, 2025

    @hardillb
    Member

    Ok that makes sense, node.warn like that is effectively a debug node.

    And the reply is correct because files end up in msg req.files not msg.payload

  10. Hugobox commented on Aug 11, 2025

    @Hugobox
    ContributorAuthor

    still crashes if function is:
    if (msg.req.files){
    msg.file = msg.req.files[0]
    }
    msg.payload = msg.file
    return msg;

    alternatively, if I use a change node setting msg.payload to msg.req.files[0], it will crash with large files

  11. Hugobox commented on Sep 8, 2025

    @Hugobox
    ContributorAuthor

    Anybody can reproduce?

  12. added theissue type on Jun 12, 2026
  13. added a commit that references this issue on Oct 7, 2026
    bce18a2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions