Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Fix Agent-API retries#899

Merged
asim-shrestha merged 7 commits intoreworkd:mainfrom
istandre:fix_retries
Jun 29, 2023
Merged

Fix Agent-API retries#899
asim-shrestha merged 7 commits intoreworkd:mainfrom
istandre:fix_retries

Conversation

@istandre
Copy link
Copy Markdown
Contributor

Changes

Per the comment written in the withRetries function, the onError function returns whether to continue. Thus, if true, we should not break out, but continue looping instead.

I also removed the second condition since it is redundant (already handled by the for loop).

Finally, the for loop is now starting with i=0, since, per my understanding, retries should be the number of retries to do after an error and not the number of tries in total (number of tries = 1 + number of retries).

Testing

I have added a test file to test the withRetries function.

Note that I have added a mock file for the window.matchMedia function to avoid polluting the tests logs.
Without the mock, even if no test fails, we see the following error in the logs:

console.error
   an error happened during hydration.  TypeError: window?.matchMedia is not a function
[...]

Note also that I have added "test" as possible values for the NEXT_PUBLIC_VERCEL_ENV env var. Even with the SKIP_ENV_VALIDATION env var enabled, the client config gets loaded and parsed via agent-api.ts (import api-utils.ts -> import client.mjs)

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 29, 2023 7:14pm

@ergomake
Copy link
Copy Markdown

ergomake Bot commented Jun 29, 2023

Hi 👋

We couldn't create a preview environment for this pull-request 😥

You can see your environment build logs here. Please double-check your docker-compose.yml file is valid.

If you need help, email us at contact@getergomake.com or join Discord.

Click here to disable Ergomake.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 29, 2023

@istandre is attempting to deploy a commit to the reworkd Team on Vercel.

A member of the Team first needs to authorize it.

@vercel vercel Bot temporarily deployed to Preview – docs June 29, 2023 18:27 Inactive
@vercel vercel Bot temporarily deployed to Preview – docs June 29, 2023 18:57 Inactive
@vercel vercel Bot temporarily deployed to Preview – docs June 29, 2023 19:05 Inactive
@vercel vercel Bot temporarily deployed to Preview – docs June 29, 2023 19:09 Inactive
@vercel vercel Bot temporarily deployed to Preview – docs June 29, 2023 19:14 Inactive
@asim-shrestha
Copy link
Copy Markdown
Contributor

Wow thanks @istandre! Would never expect people to tackle something like this, especially without an existing ticket none-the-less!

I've gone ahead and fixed up some minor stuff. Seems like the mock you included was due to the file import having a direct dependency on some stores which can't run unless they're on the browser. I've gone ahead and refactored it a bit. Also changed up some naming and ensured that the work was returning true if it should continue retrying and false otherwise (Was backwards)

Please let me know if you want to work on anything else and I'm happy to set you up with a ticket you're excited for. I'm Asim#3933 on the discord or you can email me at asim@reworkd.ai

@asim-shrestha asim-shrestha merged commit d5774aa into reworkd:main Jun 29, 2023
@istandre istandre deleted the fix_retries branch June 30, 2023 12:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants