-
Notifications
You must be signed in to change notification settings - Fork 1
adds graceful failure mode; all public functions have a try/catch (FF… #16
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
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.
I'd include unit tests that mock out bad calls for both failures modes to verify exception is thrown / null returned.
Happy to pair on the mocking if you'd like!
export default class EppoClient implements IEppoClient { | ||
private queuedEvents: IAssignmentEvent[] = []; | ||
private assignmentLogger: IAssignmentLogger | undefined; | ||
private isGracefulFailureMode = 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.
🎉
try { | ||
return ( | ||
this.getAssignmentVariation( |
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.
Since all these functions do is immediately delegate to getAssignmentVariation()
, I'm thinking it would be cleaner to just have the try
-catch
in that method and forgo it in these user-facing syntactic sugar wrappers.
src/client/eppo-client.ts
Outdated
); | ||
} catch (error) { | ||
if (this.isGracefulFailureMode) { | ||
console.error(`[Eppo SDK] Error getting assignment: ${error.message}`); |
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.
Consider just logging the error so we get the stack trace as well.
console.error('[Eppo SDK] Error getting assignment', error.message);
public setIsGracefulFailureMode(gracefulFailureMode: boolean) { | ||
this.isGracefulFailureMode = gracefulFailureMode; | ||
} |
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.
❤️
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.
yea thank you - good idea!
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 pairing and iterating! 🎉
}, | ||
}; | ||
|
||
describe('error encountered', () => { |
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.
🙌
…-968)
labels: mergeable
Fixes: #issue
Motivation and Context
Exceptions within the Eppo SDK should not bubble up to the customers' applications.
Description
By default the graceful mode is enabled; all exceptions are captured in the top level public methods and logged.
For development the graceful mode can be disabled:
How has this been tested?
It was easy to test the logger because we can pass a mock - it wasn't obvious to me how to trigger an exception to be able to test the graceful mode. We'd need to stub
getAssignmentVariation
but this seems unnecessary.Suggestions welcome.
deployment plan
Bump version number and import into upstream.