Skip to content
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

REQUEST FOR COMMENTS: Graceful shutdown of active calls #255

Merged
merged 10 commits into from
May 3, 2018

Conversation

rmccallum81
Copy link
Contributor

Accidental close of #250

@icebob
Copy link
Member

icebob commented May 2, 2018

Please fix tests

src/service.js Outdated
.reduce((p, fn) => p.then(fn), this.Promise.resolve());
}
return new this.Promise((resolve, reject) => {
const timeout = setTimeout(reject, this.settings.gracefulStopTimeout || this.broker.options.gracefulStopTimeout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it is an "internal" service settings, please follow the conventions and use the $ prefix. Please change it to this.settings.$gracefulStopTimeout

src/service.js Outdated
const contextDisposeCatch = (ret) => {
return this.Promise.reject(contextDispose(ret));
};
return innerAction.handler(ctx).then(contextDispose, contextDisposeCatch);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the common .then().catch() syntax:

return innerAction.handler(ctx).then(contextDispose).catch(contextDisposeCatch);

src/service.js Outdated
* @memberof Service
*/
_getActiveContexts() {
return this.activeContexts || [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use _ before local variable name because it can conflict with user's service variables. Use as this._activeContexts

@rmccallum81
Copy link
Contributor Author

I wonder if the transport benchmarks should be updated to include a test with and a test without context tracking. The common benchmark with the FakeTransporter showed a significantly lower reduction in performance.

@icebob icebob merged commit 0630503 into moleculerjs:master May 3, 2018
@@ -978,6 +991,14 @@ class ServiceBroker {
});
}

// Remove the context from the active contexts list
if (ctx.trackedBy) {
p.then(res => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It breaks the promise chain and throw Unhandled exception. The correct way is p = p.then.....

@@ -1007,6 +1028,14 @@ class ServiceBroker {
if (ctx.timeout > 0 && p.timeout)
p = p.timeout(ctx.timeout);

// Remove the context from the active contexts list
if (ctx.trackedBy) {
p.then(res => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants