fix: search service graceful degradation on ES unavailability (#1235) - #2
Open
Dev-Odun-oss wants to merge 1 commit into
Open
fix: search service graceful degradation on ES unavailability (#1235)#2Dev-Odun-oss wants to merge 1 commit into
Dev-Odun-oss wants to merge 1 commit into
Conversation
…eward#1235) searchService.js now degrades gracefully when Elasticsearch is unreachable: - Added isConnectivityError() to identify ConnectionError, NoLivingConnectionsError, and TimeoutError from @elastic/elasticsearch - search() catches connectivity errors, logs a warn, and returns { hits: [], total: 0, facets: {...}, durationMs } instead of propagating 500 - suggest() returns [] on connectivity errors - indexReward(), indexCampaign(), indexUser(), deleteDocument() silently continue (log warn, return undefined) on connectivity errors - ResponseError (bad query / mapping mismatch) still propagates normally - Added _setClient() test helper for reliable mock injection in unit tests Tests (tests/searchService.test.js): - ConnectionError → degraded result { hits: [], total: 0 } - NoLivingConnectionsError → degraded result - ConnectionError does NOT throw (resolves to degraded shape) - ResponseError propagates (not swallowed) - suggest() returns [] on ConnectionError - Happy path: real data returned when ES is healthy - indexReward() resolves without throwing when ES is unreachable - deleteDocument() resolves without throwing when ES is unreachable Closes Nova-reward#1235
🦀 Cargo Dependency Vulnerability Scan
|
|
Looks good to me! Approved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wraps all public search methods with connectivity-error handling so that a temporarily unreachable Elasticsearch cluster returns empty/degraded results instead of propagating unhandled 500s.
Changes
services/searchService.jsisConnectivityError()— identifiesConnectionError,NoLivingConnectionsError,TimeoutErrorfrom@elastic/elasticsearchsearch()— catches connectivity errors, logswarn, returns{ hits: [], total: 0, facets: {...}, durationMs }suggest()— returns[]on connectivity errorsindexReward(),indexCampaign(),indexUser(),deleteDocument()— resolve silently on connectivity errorsResponseError(bad queries / mapping mismatch) still propagates normally_setClient()test helper for reliable mock injection without depending on module-level mock hoistingtests/searchService.test.js— 8 unit tests covering all acceptance criteriaAcceptance Criteria
searchRewardsreturns{ hits: [], total: 0 }when ES is unreachablewarnlevel (noterror) for transient connectivity issuesConnectionErrorand verifies degraded responseResponseErrorfor bad queries still propagates normallyTesting
Closes Nova-reward#1235