-
Notifications
You must be signed in to change notification settings - Fork 89
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 errors #1656
Improve errors #1656
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1656 +/- ##
==========================================
- Coverage 97.44% 96.94% -0.51%
==========================================
Files 22 21 -1
Lines 861 818 -43
Branches 93 78 -15
==========================================
- Hits 839 793 -46
- Misses 21 25 +4
+ Partials 1 0 -1 ☔ View full report in Codecov by Sentry. |
Breaking changes:
|
I've looked into |
expect(response).toHaveProperty('hits'); | ||
expect(Array.isArray(response.hits)).toBe(true); |
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.
Old way was checking with instanceof
internally, but it is clearly sated in the docs that arrays are not to be checked this way: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray#description
With builtin Node.js fetch
this was failing with the old way.
These changes might appear daunting at first, but it's mostly tests, and because tests are repeated ad nauseam with very little generalization, you've seen 3 types of changes and you've seen them all. |
Well, actually some more details about the However, browsers don't give a damn. Only Firefox prints it at this moment, and unless But there's still hope, chromium is working on it: https://issues.chromium.org/issues/40182832 Still, it's not like the old errors we have had any of their bespoke properties printed, so it's still an improvement, and it's future-proof. |
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.
Hi @flevi29 thanks a lot for this PR!
I just want to ask you to create a small guide to the user if there is any upgrade path. Since you told us that there is no breaking in the js-plugins, I guess it should be shorter. But in any case I need something to put into the release :)
bors merge |
Hi @brunoocasali sorry for the late response. Errors now make use of the standardized
New: |
1695: Update version for the next release (v0.42.0) r=brunoocasali a=meili-bot _This PR is auto-generated._ The automated script updates the version of meilisearch-js to a new version: "v0.42.0" CHANGELOGS 👇 This version introduces features released on Meilisearch v1.10.0 🎉 Check out the changelog of [Meilisearch v1.10.0](https://github.com/meilisearch/meilisearch/releases/tag/v1.10.0) for more information on the changes. ##⚠️ Breaking changes * Improve errors (#1656) `@/flevi29` More details [here](#1656 (comment)) * Changes related to Hybrid search (experimental) for the REST embedder (#1692) `@/mdubus` - Removed parameters: `query`, `inputField`, `inputType`, `pathToEmbeddings` and `embeddingObject`. - Replaced by `request` and `response` - New parameter: `headers` ## 🚀 Enhancements * Hybrid search improvements (#1692) `@/mdubus` - Add `url` parameter to the OpenAI embedder - `dimensions` is now available as an optional parameter for `ollama` embedders. * Add federated search parameters (#1689) `@/flevi29` ```js client.multiSearch({ federation: {}, queries: [ { indexUid: 'movies', q: 'batman', limit: 5, }, { indexUid: 'comics', q: 'batman', limit: 5, }, ] }) ``` * Add capabilities to update documents by function (#1691) `@/flevi29` ```js index.updateDocumentsByFunction({ context: { ctx: 'Harry' }, filter: 'id = 4', function: 'doc.comment = `Yer a wizard, ${context.ctx}!`', }) ) ``` * Add language settings (#1693) `@/flevi29` ```js client.index('INDEX_NAME').updateLocalizedAttributes([ { attributePatterns: ['jpn'], locales: ['*_ja'] }, ];) ``` * Add `locale` search parameter (#1693) `@/flevi29` ```js client.index('INDEX_NAME').search('進撃の巨人', { locales: ['jpn'] }) ``` ## ⚙️ Maintenance/misc * Add JS hosted documentation (#1678) `@/amit-ksh` Co-authored-by: meili-bot <[email protected]>
Pull Request
Related issues
Fixes #1612, #1655
What does this PR do?
This PR aims to improve errors, so that they can contain all the necessary information, and more.
jsdom
from replacingfetch
andAbortController
for consistency with node tests, replacing previous solution where we removed the builtinfetch
from node tests"abort-controller"
package, it was only used in tests and nowAbortController
is always availableMeiliSearchCommunicationError
toMeiliSearchRequestError
, as this error might not be entirely related to communication, but rather the request itselfcause
, preserving the original error, simplifying things, taking advantage of modern browsers and runtimes actually printing this propertyObject.setPrototypeOf
in errors, this is not needed in modern browsers, and bundlers take care of it if we need to support older browsers (so in UMD bundle it's done twice currently). (https://stackoverflow.com/a/76851585)Error.captureStackTrace
, this is done by the baseError
constructor, and it's only available in V8 engine based browsers/runtimesfetch
to re-throw it asMeiliSearchRequestError
, other potential errors should propagate as they're either truly unexpected or are thrown by us, simplifying error handling and not putting unexpected errors under theMeiliSearchError
umbrellaMeiliSearchErrorInfo
type toMeiliSearchErrorResponse
NOTE: Tests are horrifying, I didn't change all that much in src, but I had to change almost every test and by quite a bit. Testing is what I should aim to improve ASAP.