-
Notifications
You must be signed in to change notification settings - Fork 90
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
Improve HttpRequests
#1741
base: main
Are you sure you want to change the base?
Improve HttpRequests
#1741
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1741 +/- ##
==========================================
+ Coverage 98.84% 99.24% +0.39%
==========================================
Files 17 17
Lines 1565 1594 +29
Branches 338 349 +11
==========================================
+ Hits 1547 1582 +35
+ Misses 18 12 -6 ☔ View full report in Codecov by Sentry. |
src/clients/client.ts
Outdated
body: params, | ||
})) as EnqueuedTaskObject; | ||
|
||
return new EnqueuedTask(taks); | ||
} |
There was a problem hiding this comment.
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
tests/client.test.ts
Outdated
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", | ||
); | ||
}); |
There was a problem hiding this comment.
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.
…-js into improve-http-request
For now I've made the requested changes, but I do plan to add better documentation to |
I'm also deprecating |
It's not a breaking change, because it's a positional parameter, not an object property in the |
Actually the private properties change is non-breaking, because |
Hey @flevi29, sorry we couldn't get this in time for #1826. The next pre-release cycle starts on January 27 and I wanted to have time at least 2 weeks to fix bugs before getting into the new features implementation. But I think this PR is already in a good state. We'll probably be able to merge it soon after updating the package for Meilisearch 1.13. |
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 😅. |
Once v1.13 is out, merging your PR will be the priority @flevi29 😉 |
Pull Request
Sorry for the huge PR, but
HttpRequests
is core, and is used everywhere.What does this PR do?
EnqueuedTaskObject
s not being converted toEnqueuedTask
Caution
BREAKING
Rename
Config.requestConfig
->Config.requestInit
,signal
can no longer be passed to it.Warning
Deprecate
Config.httpClient
#1824PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!