-
Notifications
You must be signed in to change notification settings - Fork 789
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
Fix error handling for metrics #1
Conversation
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.
Great stuff! Just 2 small comments, then we should be good
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.
Thanks for fixing this. Man, that error handling.
src/shadowbox/server/ip_util.ts
Outdated
}); | ||
}); | ||
}); | ||
export class CachedIpLocationService implements IpLocationService { |
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.
Servers could stay up for weeks - let's file an issue to make this cache:
- bounded in size
- an expiring cache
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.
Added the comment. We should make it LRU.
src/shadowbox/server/ip_util.ts
Outdated
fulfill('ZZ'); | ||
} | ||
} catch (e) { | ||
reject(new Error(`Error loading country from reponse: ${e}`)); |
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.
Seems like there's a chance this could log the IP address - I'd feel better if we weren't logging the error verbatim.
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.
Removed the cause error
countryPromises.push(lookupCountry(ip)); | ||
const countryPromise = ipLocationService.countryForIp(ip).catch((e) => { | ||
console.warn('Failed countryForIp call: ', e); | ||
return '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.
It's hard to figure out what the outcome of this is - are you filtering the unsuccessful lookups?
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.
We save the country as ERROR
on unsuccessful lookups
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.
OK...and that makes it right through to BigQuery?
I think you should remove the console.warn
. Seems like logging on first failure is sufficient.
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.
This is the only place we log. The IpLocationService doesn't log anything.
I consider a good approach to log errors only where you handle them (like here). This about the duplicate logging.
src/server_manager/web_app/main.ts
Outdated
if (!queryParam) { | ||
return null; | ||
} | ||
if (typeof(queryParam) === 'string') { |
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.
IIRC, testing for strings is a minefield in JavaScript. Array.isArray
might be safer.
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.
Changed to Array.isArray
@fortuna One more request - and please consider a squash commit when merging. |
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.
👍
* chore: upgrade to lts/hydrogen * update github workflows * fix attempt #1 * ssl, restify upgrade * more openssl options * ah thanks sander, using middleware2 * fix ci * reset package-lock.json * revert middleware2 * fix optional chaining * okay cool tests run, but fail * partially update the node image (i can't find the other one) * Update test.action.sh * Update build.action.sh * Update test.action.sh * Update build.action.sh * Update package.json * Update webpack.config.js * Update webpack.config.js * Update build.action.sh * Update build.action.sh * Update package.json * Update README.md
cc @trevj @sandrigo FYI