Skip to content

FileStreamDisconnectUploadError when checking file validity #65

@FreddyPoly

Description

@FreddyPoly

Hello,

The problem

I have a problem when checking for the validity of the files sent by multipart request from the client side.

The client sends a multipart request with maximum 5 different files, then the server loops through them to check if every file is an instance of stream.Readable. While looping through the files an error occures: FileStreamDisconnectUploadError: Request disconnected during file upload stream parsing..

The first file is checked but then the others files are never read.

This is what my loop looks like:

for (const pic of data.pictures) {
      const resolved = await pic;
      if (!(resolved.stream instanceof stream.Readable)) return new Error('Wrong file');
}

The error is raised when executing the line const resolved = await pic;.
The first file fills the resolved variable but it never gets filled again with the next files.

What I tried

  • I tried to destroy the stream after the check: resolved.stream.destroy();
  • I tried to replace the for...of loop with a map

Some thoughts

Before making the requests by the client, I sent the requests using curl according to these examples. But the error still occured.

I work on a Macbook with MacOS Sierra 10.12.6 and curl 7.54.0 which uses SecureTransport, as it is the native TLS library.

What is interesting is that my coworkers, which work with the same Macbook as mine but with MacOS High Sierra and curl 7.54.0 which uses LibreSSL as TLS library, manage to get the requests work with the server. Of course we tried with the exact same requests and on a server running on my mac.

Do you have any idea why the error occures and why does the await pic never manage to complete ?

Thanks for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions