Skip to content

Improve HttpRequests #1741

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

Merged
merged 53 commits into from
Mar 12, 2025
Merged

Conversation

flevi29
Copy link
Collaborator

@flevi29 flevi29 commented Oct 9, 2024

Pull Request

Sorry for the huge PR, but HttpRequests is core, and is used everywhere.

What does this PR do?

Caution

BREAKING

Rename Config.requestConfig -> Config.requestInit, signal can no longer be passed to it.

Warning

Deprecate Config.httpClient #1824

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.36%. Comparing base (dafbb44) to head (cf636f9).
Report is 54 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1741      +/-   ##
==========================================
+ Coverage   98.95%   99.36%   +0.40%     
==========================================
  Files          16       16              
  Lines        1537     1566      +29     
  Branches      332      343      +11     
==========================================
+ Hits         1521     1556      +35     
+ Misses         16       10       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@flevi29 flevi29 added maintenance Issue about maintenance (CI, tests, refacto...) breaking-change The related changes are breaking for the users and removed maintenance Issue about maintenance (CI, tests, refacto...) labels Oct 9, 2024
@flevi29 flevi29 linked an issue Oct 10, 2024 that may be closed by this pull request
body: params,
})) as EnqueuedTaskObject;

return new EnqueuedTask(taks);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bug: previously this did not return EnqueuedTask, but rather EnqueuedTaskObject

Comment on lines 72 to 95
test(`${permission} key: Create client with custom headers (object)`, async () => {
const key = await getKey(permission);
const client = new MeiliSearch({
...config,
apiKey: key,
requestInit: {
headers: {
"Hello-There!": "General Kenobi",
},
},
},
});

assert.isTrue(await client.isHealthy());

assert.isDefined(fetchSpy.mock.lastCall);
const [, requestInit] = fetchSpy.mock.lastCall!;

assert.isDefined(requestInit?.headers);
assert.instanceOf(requestInit!.headers, Headers);
assert.strictEqual(
(requestInit!.headers! as Headers).get("Hello-There!"),
"General Kenobi",
);
});
Copy link
Collaborator Author

@flevi29 flevi29 Oct 10, 2024

Choose a reason for hiding this comment

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

Because headers are internal implementation details, to check them we have to spy on fetch now.

@flevi29 flevi29 marked this pull request as ready for review October 11, 2024 08:37
@flevi29 flevi29 requested a review from brunoocasali October 11, 2024 11:00
@flevi29
Copy link
Collaborator Author

flevi29 commented Jan 15, 2025

Alright, no problem, I just didn't know you guys talked before releasing. But to be fair I'm also excited to get my PRs merged 😅.

@curquiza
Copy link
Member

curquiza commented Jan 15, 2025

Once v1.13 is out, merging your PR will be the priority @flevi29 😉
Thank you very much for your work, as always!

@flevi29 flevi29 linked an issue Feb 3, 2025 that may be closed by this pull request
8 tasks
@flevi29 flevi29 mentioned this pull request Feb 4, 2025
8 tasks
@flevi29 flevi29 requested a review from Strift March 3, 2025 09:50
@Strift
Copy link
Collaborator

Strift commented Mar 9, 2025

All good for me @flevi29. If you can fix the small conflicts, I'll get this merged. Thanks for the great work!

@flevi29
Copy link
Collaborator Author

flevi29 commented Mar 9, 2025

@Strift fixed

Copy link
Collaborator

@Strift Strift left a comment

Choose a reason for hiding this comment

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

Alright, let's do this 🔥

bors merge

Copy link
Contributor

meili-bors bot commented Mar 12, 2025

Build succeeded:

@meili-bors meili-bors bot merged commit 9e43b62 into meilisearch:main Mar 12, 2025
8 checks passed
@flevi29 flevi29 deleted the improve-http-request branch March 12, 2025 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change The related changes are breaking for the users bug Something isn't working maintenance Issue about maintenance (CI, tests, refacto...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timeout implementation for requests should be re-thought
3 participants