-
Notifications
You must be signed in to change notification settings - Fork 107
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
feat: optional timeout (#200) #202
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.
There is currently a default timeout value, so this will not do anything unless the user provides options.timeout = null
(or undefined or 0). This is the way I would prefer it, but I just want to clarify that is the case.
Can you please add a test for this?
I'm aware of the default value. On my project, I'm setting the timeout as false, so it's more clear and the default behaviour is still the same, so we aren't doing any breaking changes. Not sure how I could test this, any tips @lance? |
@duartemendes it's non-optimal because of the fact that it will take > 1 second, but here is a stake in the ground. test('timeout is not called', t => {
t.plan(1);
// set up circuit breaker with timeout disabled
const cb = circuitBreaker(timedFunction(3000), { timeout: false } );
cb.on('timeout', t.fail);
// 1000ms is the default timeout value
// this test passes if we exceed this timeout value
setTimeout(t.ok, 1500);
cb.fire();
}); EDIT Fix example so it makes sense If you could also add a note to the docs indicating this behavior, I would appreciate it. Thanks! |
@duartemendes I've made these changes locally but can't push to your branch. Here is a diff: https://gist.github.com/lance/6a630d182cdad6ec8456bf3ee42afbcd |
fa4e71f
to
f6b63b2
Compare
@lance sorry for the delay, went for a little vacation. I understand your test, however isn't the default timeout 10000ms? :) I tried the test with timedFunction as 12000 and timeout as 15000 but tests started failing:
Updated the docs though. |
@duartemendes OMG - an extra zero makes a lot of difference. Thanks for your help with this! |
No problem @lance! Please update package on npm :) |
@duartemendes 1.7.0 is now available on npmjs.com and here https://github.com/bucharest-gold/opossum/releases/tag/v1.7.0 |
No description provided.