Skip to content

How to handle body timeout error? #1671

@paymog

Description

@paymog

Bug Description

I have a fastify server which uses undici. I'm seeing the following errors intermittently:

BodyTimeoutError: Body Timeout Error
    at Timeout.onParserTimeout [as _onTimeout] (/app/node_modules/undici/lib/client.js:896:28)
    at listOnTimeout (node:internal/timers:561:11)
    at processTimers (node:internal/timers:502:7)
Emitted 'error' event on BodyReadable instance at:
    at BodyReadable.emit (/app/node_modules/undici/lib/api/readable.js:66:18)
    at emitErrorNT (node:internal/streams/destroy:164:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'UND_ERR_BODY_TIMEOUT'
}

Unfortunately, this stack trace doesn't indicate where I should put a try/catch to swallow this error.

I have a reply.From which has looks like so

    reply.from(pathname || '/', {
      getUpstream: () => origin,
      onError: (rep, err) => {
        // ...
      },
      onResponse: async (_, rep, res) => {
          // ...
        });
      },
    });

It seems that the body timeout error is either happening elsewhere in my server or is not triggering the onError handler.

Expected Behavior

I'd expect this stack trace to give more information on where this error is originating so that I can put a try/catch around it

Environment

a docker container based on node:17-alpine

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions