Skip to content

Instrumentation causing FormData Error #135

@KevinEonix

Description

@KevinEonix

Hi, i had a lot of trouble with this.
We have a NerxtJs app. We use the route handlers as a BFF (Backend For Frontend) to keep the tokens in the backend.

The problem is: When the instrumentation is active (with only the service name)

import {registerOTel} from '@vercel/otel'

export function register() {
    registerOTel({serviceName: 'MyApp'})
}

Our Other api (in .Net) throw an error

      An unhandled exception has occurred while executing the request.
      System.IO.IOException: Unexpected end of Stream, the content may have already been read by another component. 

Does the vercel otel package modify the body in any way ?
But i tested everything: the dotnet api, the next middleware, the docker environment, the Reverse Proxy (Traefik) configuration.
The only thing that's causing the problem is the instrumentation hook

Tested on both Next version 14.2.18 and 15.0.3 and we have the same error

the route handler code :

const fd = await req.formData();

        const query = await fetch('http://localhost:5098/api/test-formdata', {
            method: 'POST',
            body: fd,
        })

        if (query.ok) {
            console.log('working')
        }
        else {
            console.log('query not ok');
        }

and the input file that send the formdata to the Next Api

<input type="file" onChange={async e => {
          const f = e.currentTarget.files![0];

          const fd = new FormData();
          fd.append("document", f as File);

          const query = await fetch('/api/test', {method: 'POST', body: fd});
        }}/>

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