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

Allow users to set custom timeout to the requests #1032

Closed
wants to merge 4 commits into from
Closed

Allow users to set custom timeout to the requests #1032

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 5, 2021

This pull request should fix #716

Copy link
Contributor

@bidoubiwa bidoubiwa left a comment

Choose a reason for hiding this comment

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

Hello! @AsianCat54x
Thanks for your contribution :)

Can I ask you the following before reviewing your code:

  • Change the title of the PR to something more explicit. We do not have any rules except that the name of the PR should follow the sentence This PR will.....

For example if my pr fixes a typo in the readme the title would be Fixes typo in README/

  • Fix the linting errors.
    Both the code and the code formatting are tested. At this section of the CONTRIBUTING you can see that you have yarn style and yarn style:fix. The latter will fix the code automatically for you!

@ghost
Copy link
Author

ghost commented Oct 6, 2021

So shall I keep somethings like this: This PR will fix issue #716

Alright so I actually didnt see CONTRIBUTING.md. (My bad)

So all I need to do is lint the code with yarn.

So what about the AbortController error? (Here is a stackoverflow nswer - https://stackoverflow.com/a/58232108/16789038)

@bidoubiwa
Copy link
Contributor

About the name while it does fix issue 716, the title should explain what the code in the PR fixes, not which issue is fixed. For that we use the Linked issue section.

So, the question you have to ask yourself is This PR will .... What does your code do?

About the AbortController issue it is because you don't import it. But 'ill get to your code review once the formatting and the name have been fixed.

@ghost
Copy link
Author

ghost commented Oct 6, 2021

Oh I see! Alright I will think of a good title

I dont know why I am getting error while running yarn style but I am trying to solve that!

@bidoubiwa
Copy link
Contributor

did you try yarn style:fix ? It should automatically fix the majority of errors you have

@ghost ghost changed the title Fix issue #716 Allow users to set custom timeout to the requests Oct 6, 2021
@ghost
Copy link
Author

ghost commented Oct 6, 2021

Firstly when I ran yarn style, I got this error message ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".. Searching in google gave this stackoverflow link

And btw, Is the title good?

Will using vscode's eslint do the trick?

@bidoubiwa
Copy link
Contributor

The title of the issue is great!

Did you install the dependencies? yarn install ?

@ghost
Copy link
Author

ghost commented Oct 6, 2021

I ran yarn install but the error presisted, but now that I ran this command, the linter is working fine.

Now that the command is running, I am linting all the files and committing

@bidoubiwa
Copy link
Contributor

Good work for the styling!

Now when you work on a PR it is better to get the tests running so you know when you are breaking the code.
In our case, to make the tests work you need a running instance of MeiliSearch on your computer.
As showed here you can run MeiliSearch with docker:

docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearch image from Docker Hub
docker run -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics=true

Or with another method explained in the documentation.

You can also follow the getting started of MeiliSearch to understand better.

Tell me when you have a running MeiliSearch

@bidoubiwa
Copy link
Contributor

Oke! Now you should run the tests by doing yarn test they should fail as your code is not working.

@ghost
Copy link
Author

ghost commented Oct 6, 2021

@bidoubiwa Good news here! All the test passed yay!

Here is a picture:

Note: I have edited some files

@bidoubiwa
Copy link
Contributor

Are you using node version 16 ?

@ghost
Copy link
Author

ghost commented Oct 6, 2021

Yes, v16.10.0

@bidoubiwa
Copy link
Contributor

I don't think it is working in previous versions of node. So the question is, do we want to add a package abort-controller to the package.

I don't think we want :s

@ghost
Copy link
Author

ghost commented Oct 6, 2021

Yeah, I installed abort controller and then ran the tests, it ran perfectly.

Should I commit the changes I have made?

If you dont want to add the abort-controller package, I could just use any other solutions to do the trick.

@bidoubiwa
Copy link
Contributor

Are their other solutions than abort-controllers ? Yes I think tests fail with node 14 as abort controller is introduced in node 16.

@bidoubiwa
Copy link
Contributor

Hey @AsianCat54x i will be reviewing your pr next week!

@ghost ghost requested a review from bidoubiwa October 12, 2021 12:17
@ghost
Copy link
Author

ghost commented Oct 12, 2021

Hey @bidoubiwa, can you review?

@ghost
Copy link
Author

ghost commented Oct 18, 2021

@bidoubiwa, am I missing something?

Copy link
Contributor

@bidoubiwa bidoubiwa left a comment

Choose a reason for hiding this comment

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

Sorry very busy weeks
It seems to work fine :) Could you add some tests to ensure this is not provokings any bugs?

Also you used 'Error: Request Timed Out', but there is a MeiliSearchTimeoutError in /errors could you use this one when a timeout is thrown?

Comment on lines 57 to 66
const controller = new AbortController()

if (this.timeout === undefined) {
this.timeout = 3000
}

setTimeout(() => {
controller.abort()
}, this.timeout)

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move your code inside the try scope?

Copy link
Author

Choose a reason for hiding this comment

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

Actually, that error doesn't do anything. I kind of forget to remove that. Anyway, It will be required to add tests.

@ghost
Copy link
Author

ghost commented Oct 25, 2021

Hey, @bidoubiwa, I guess the only task left is to add tests, right? Its just that I am not able to create one. Can you help me by telling in which file I should make and where?

@bidoubiwa
Copy link
Contributor

I would be glad to help you through this task. I'm adding the hacktoberfest-accepted to avoid being to late for the end of the event. If you are willing to wait a bit I will make an example of a test you can use.

If you are participating in Hacktoberfest, and you would like to receive a small gift from MeiliSearch too, please complete this form.

@ghost
Copy link
Author

ghost commented Oct 26, 2021

Yeah, I am participating in Hacktoberfest! Thanks, @bidoubiwa!

@bidoubiwa
Copy link
Contributor

Hello @0xsapphir3
I wasn't able to make your code work. Unfortunately I do not have the time to make the research on the proper way to make it work.
If you find a working solution please consider re-opening a PR :)

@bidoubiwa bidoubiwa closed this Feb 9, 2022
@ghost
Copy link
Author

ghost commented Feb 11, 2022

Sure :)

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

Successfully merging this pull request may close these issues.

The user should be able to change the requests timeout
3 participants