Closed rosado closed 4 days ago
Status | Category | Percentage | Covered / Total |
---|---|---|---|
šµ | Lines | 67.93% | 4415 / 6499 |
šµ | Statements | 67.93% | 4415 / 6499 |
šµ | Functions | 67.37% | 190 / 282 |
šµ | Branches | 82.4% | 548 / 665 |
File | Stmts | Branches | Functions | Lines | Uncovered Lines |
---|---|---|---|---|---|
Changed Files | |||||
src/middleware/issueDetails.middleware.js | 80.34% | 62.5% | 41.66% | 80.34% | 51-63, 76-99, 207-213, 227-230, 233-236, 240-244 |
src/middleware/middleware.builders.js | 87.13% | 88.57% | 83.33% | 87.13% | 36, 104-115, 128-141, 258-261, 282-290 |
src/middleware/overview.middleware.js | 86.58% | 85.71% | 57.14% | 86.58% | 10-12, 24, 32, 46-50, 68-69, 116-125 |
src/serverSetup/errorHandlers.js | 0% | 0% | 0% | 0% | 1-46 |
src/services/performanceDbApi.js | 64.47% | 92.59% | 35.71% | 64.47% | 49-77, 114-116, 179-183, 234-240, 251-264, 273-293, 297-305, 314-326, 337-364, 374-379 |
The changes primarily involve refactoring middleware functions across several files to enhance modularity and error handling. Key modifications include the introduction of new utility functions for handling promise rejections and updates to existing middleware to utilise these new functions. The structure of data being handled has also been modified, particularly in how counts are represented. Overall, the changes aim to streamline the middleware architecture and improve error management.
File | Change Summary |
---|---|
src/middleware/issueDetails.middleware.js |
Refactored fetchIssues and fetchIssueEntitiesCount to use fetchMany and fetchOne . Updated handling of issueEntitiesCount to be an object. Minor adjustments to request parameter destructuring. |
src/middleware/middleware.builders.js |
Added safeFn for error handling and handleRejections to wrap middleware functions for promise rejection management. |
src/middleware/overview.middleware.js |
Wrapped fetchEntityCounts with handleRejections to improve error handling. No changes to function logic. |
src/serverSetup/errorHandlers.js |
Added checks for res.headersSent in error handling and 404 middleware to prevent modifying responses after headers are sent. |
src/services/performanceDbApi.js |
Introduced issuesQueryLimit , refactored methods to accept request objects for queries, and removed getEntityCount . Enhanced error handling in getEntityCounts . |
test/unit/middleware/issueDetails.middleware.test.js |
Updated tests to reflect changes in issueEntitiesCount structure from integer to object with count property. |
test/unit/middleware/middleware.builders.test.js |
Added tests for the new handleRejections function to ensure proper error handling and invocation of wrapped middleware. |
š° In the meadow, changes bloom,
Middleware now dispels the gloom.
With rejections handled right,
Errors fade out of sight.
Count the issues, one, two, three,
A modular world, hop with glee! š¼
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
showing as done - but no end date?
What type of PR is this? (check all applicable)
Description
Due to the combination of the following:
fetchOne
/fetchMany
) don't handle promise rejectionsWe sometimes end up with unhandled errors (e.g. in
fetchEntry()
).We can't switch to 5.x (at least not easily, the wizard library relies on something that broke between 4.x and 5.x), so we have to handle this explicitly. This PR adds a wrapper middleware to handle such errors for the few cases where
fetchOne()
/fetchMany()
isn't used. 500 error is returned now.Also, moves some of the data fetches to use generic middleware and removes some dead code.
Related Tickets & Documents
No ticket, but related Sentry error
Added/updated tests?
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Documentation
Tests