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

⚠️ ui.upload File upload stops at 99.9% #2918

Open
adarshpunj opened this issue Apr 19, 2024 · 4 comments
Open

⚠️ ui.upload File upload stops at 99.9% #2918

adarshpunj opened this issue Apr 19, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@adarshpunj
Copy link

Description

I checked a previous issue related to this which was closed. However, I'm still facing this issue.

Interestingly, it's working normally on my Mac. Though, it stops at 99.9% on a Linux VM. Note that I'm using Docker image in both cases.

Version - 1.4.22

I'm able to reproduce this on both Firefox on Chrome.

I didn't encounter this issue with file size < 1 MB. I tested two files 5 MB and 29 MB, where the upload fails (or passes) at 99.9%

Attaching my code if that helps:

ui.upload(
       on_upload=lambda e: self.fn(e=e),
       label="",
       auto_upload=True,
       multiple=False,
    ).props("accept=.csv")

The function self.fn

def _handle_file_upload(e: events.UploadEventArguments):
    file = e.content
    global df
    df = pd.read_csv(filepath_or_buffer=file, encoding="latin")

    _table.refresh(...)
@falkoschindler
Copy link
Contributor

Thanks, @adarshpunj!

So I assume we can boil it down to this reproduction:

ui.upload(on_upload=lambda e: ui.notify(f'{len(e.content.read())} bytes'), auto_upload=True)

Unfortunately I can't reproduce it on my Mac. Can anyone else help?

@falkoschindler falkoschindler added the help wanted Extra attention is needed label Apr 23, 2024
@adarshpunj
Copy link
Author

@falkoschindler - The culprit here is nginx.

So whenever you upload a file bigger than 1 MB (which is max limit for nginx by default), nginx doesn't allow it on the server and NiceGUI hangs at 99.9%.

I was able to solve it by changing the client_max_body_size in nginx config.

I believe this can be troublesome in production environments, hence an error message from NiceGUI end will be helpful.

@falkoschindler
Copy link
Contributor

Oh wow, thanks for the update, @adarshpunj!
Do you have an idea how NiceGUI could check for this limitation? We'd love to show a warning or error message, but I'm not sure how to trigger it.

@adarshpunj
Copy link
Author

Sure, I'm looking into it, will update once I have some info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants