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

try to fix upload file bug #695

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions skyvern/webeye/actions/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,9 @@ async def chain_click(
is_filechooser_trigger = False

async def fc_func(fc: FileChooser) -> None:
await fc.set_files(files=file)
nonlocal is_filechooser_trigger
is_filechooser_trigger = True
await fc.set_files(files=file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider ensuring the file setting operation is successful before setting is_filechooser_trigger to True. This can help avoid potential race conditions where the trigger is marked true but the file setting fails.


page.on("filechooser", fc_func)
LOG.info("Registered file chooser listener", action=action, path=file)
Expand Down Expand Up @@ -833,11 +833,11 @@ async def fc_func(fc: FileChooser) -> None:
finally:
LOG.info("Remove file chooser listener", action=action)

# Sleep for 10 seconds after uploading a file to let the page process it
# Sleep for 15 seconds after uploading a file to let the page process it
# Removing this breaks file uploads using the filechooser
# KEREM DO NOT REMOVE
if file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increasing the sleep duration from 10 to 15 seconds is a hardcoded solution to a timing issue. Consider implementing a more dynamic check to ensure the file has been processed, such as observing page changes or specific events.

await asyncio.sleep(10)
await asyncio.sleep(15)
page.remove_listener("filechooser", fc_func)

if action.file_url and not is_filechooser_trigger:
Expand Down
Loading