-
Notifications
You must be signed in to change notification settings - Fork 483
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
Handle Error stored in redux trace.traces #195
Conversation
Signed-off-by: Joe Farro <[email protected]>
@simonrobb can you look this over when you get the chance? |
Codecov Report
@@ Coverage Diff @@
## master #195 +/- ##
==========================================
- Coverage 91.5% 91.46% -0.04%
==========================================
Files 95 95
Lines 2130 2133 +3
Branches 434 435 +1
==========================================
+ Hits 1949 1951 +2
- Misses 160 161 +1
Partials 21 21
Continue to review full report at Codecov.
|
src/model/search.js
Outdated
@@ -83,7 +86,7 @@ export function getTraceSummary(trace: Trace): TraceSummary { | |||
* @return {TraceSummaries} The `{ traces, maxDuration }` value. | |||
*/ | |||
export function getTraceSummaries(_traces: Trace[]): TraceSummaries { | |||
const traces = _traces.map(getTraceSummary); | |||
const traces = _traces.map(getTraceSummary).filter(Boolean); |
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.
not sure I am following the typing here: _traces
is an array of Trace
objects, how could getTraceSummary
function be called with an Error
object?
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.
It's an inefficiency or irregularity in the state of static typing in the repo. Some files have flow-types and some do not.
The type here is really (Trace | Error)[]
.
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.
so maybe the fix should be (using Scala-ish notation)
_traces.filterNot(_ instanceof Error).map(getTraceSummary);
?
or even do the filtering somewhere upstream, instead of propagating the mixed type deeper.
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.
Agreed. At the least, if it's possible for there to be Error
objects present, the parameter type should be annotated like you described, getTraceSummaries(_traces: (Trace | Error)[]): TraceSummaries
.
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.
@yurishkuro Great point. I will filter then get the summary. I don't want to filter it further upstream because the presence of the error will be useful in resolving #51.
Note, the following code was not possible due to Flow flagging it as an error:
const traces = _traces.filter(item => !(item instanceof Error)).map(getTraceSummary);
src/model/search.js
Outdated
@@ -83,7 +86,7 @@ export function getTraceSummary(trace: Trace): TraceSummary { | |||
* @return {TraceSummaries} The `{ traces, maxDuration }` value. | |||
*/ | |||
export function getTraceSummaries(_traces: Trace[]): TraceSummaries { | |||
const traces = _traces.map(getTraceSummary); | |||
const traces = _traces.map(getTraceSummary).filter(Boolean); |
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.
Agreed. At the least, if it's possible for there to be Error
objects present, the parameter type should be annotated like you described, getTraceSummaries(_traces: (Trace | Error)[]): TraceSummaries
.
Filter in getTraceSummaries instead of further upstream because the presence of the Error will be useful in resolving #51. Signed-off-by: Joe Farro <[email protected]>
* Fix 166 - Handle Error objs in redux trace.traces Signed-off-by: Joe Farro <[email protected]> * Filter for Error objs one level higher Filter in getTraceSummaries instead of further upstream because the presence of the Error will be useful in resolving #51. Signed-off-by: Joe Farro <[email protected]> Signed-off-by: vvvprabhakar <[email protected]>
Fix #166.
HTTP responses >= 400 (e.g. 404s) cause an
Error
to be added to the redux store intrace.traces[traceID]
. This PR prevents the search page from treating them as a normal trace.