Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected end of form at Multipart._final #362

Closed
albertshinBFG opened this issue Feb 28, 2023 · 4 comments
Closed

Unexpected end of form at Multipart._final #362

albertshinBFG opened this issue Feb 28, 2023 · 4 comments

Comments

@albertshinBFG
Copy link

Greetings!

Any help here would be appreciated...
Super strange issue here. I have a React/Node.js application paired with Apollo GraphQL and Express.
I've implemented graphql-upload in addition to apollo-upload-client in the frontend to be able to upload files such as CSVs to Google Cloud Storage.

When developing locally, everything works just fine. I'm able to select the file to upload and stream it up to GCS.

However, once I deployed my changes via Google Cloud Run, I started getting this error:

Error: Unexpected end of form
    at Multipart._final (/usr/src/app/node_modules/busboy/lib/types/multipart.js:588:17)
    at callFinal (internal/streams/writable.js:610:10)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

This error is only occurring when deployed on GCP.
Any ideas as to why this could be happening?

Node Version: 14.20.1
apollo-upload-client: ^17.0.0
graphql-upload: ^16.0.2
apollo-server-express: ~2.14.3
express: ~4.17.1
graphql: ~15.5.0

@albertshinBFG
Copy link
Author

@jaydenseric
Copy link
Owner

I'm not familiar with Google Cloud Run, but maybe this issue is relevant:

#129

This comment generally applies for both the Google Cloud Functions and AWS Lambda issues:

#155 (comment)

Just googling quickly, it seems Google Cloud run has a request size limit of 32 MB:

https://cloud.google.com/run/quotas

So, maybe it's cutting your requests off early if you are exceeding that?

@albertshinBFG
Copy link
Author

albertshinBFG commented Mar 11, 2023

Hey @jaydenseric Thank you for your response!

I should clarify my problem as I'm more clear as to what may be going wrong.

I have two express servers. The first one intercepts all requests from the Frontend prior to passing the request to the backend.

Locally, this first express server isn't in use and is only in use when deployed. This is where the issue is happening and hence the difference between local and deployed.

The issue is definitely happening in this client-side express server as I have graphqlUpload implemented in my backend server and without the client-side one this whole flow works perfectly.

How do you suggest passing this multipart form from one express server to another?

I've tried to use graphqlUploadExpress middleware in my client-side express server but it still doesn't work. Do I have to use multer here?

Here's a flow chart of when it is working:

Frontend GraphQL Request -> Apollo Client (with apollo-upload-client) -> Apollo Server Express (using graphql-upload-minimal) -> Resolver (using graphql-upload-minimal scalar)

This Flow works

Here's a flow chart of when its not working
Frontend is built using express.
Frontend GraphQL Request -> Apollo Client (with apollo-upload-client) -> Express Server (sends requests to backend after Google Auth Check) -> Apollo Server Express (using graphql-upload-minimal) -> Resolver (using graphql-upload-minimal scalar)

It errors out at the Express Server. Confused as to why this extra Express layer is causing "Unexpected End of Form at Multipart._final" errors from busboy.

Any ideas would be appreciated here

@jaydenseric
Copy link
Owner

The problem of forwarding a GraphQL multipart request (or just part of a request) from one server to another is a well known, and in many cases a solved, problem that's particularly relevant for federated GraphQL API proxies/gateways that stitch together over HTTP multiple GraphQL APIs. This issue for example relates to that: #194 .

In your case, you might not need to do anything particularly complicated if you don't need to deconstruct the GraphQL request and only forward parts of it to other servers responsible for fulfilling those individual parts; you might be able to somehow pass through the entire multipart request stream without much effort. It's not something I've done before though, so I'm not sure exactly the best way to tackle it.

Helping out further with this is really beyond the scope of maintaining this package because it's more about setting up your particular server infrastructure. Feel free to share the final solution you come up with here, in case it helps others with a similar question.

@jaydenseric jaydenseric closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants