-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
delivers a will waits for authorization #213
Conversation
lib/client.js
Outdated
that.broker.persistence.delWill({ | ||
id: that.id, | ||
brokerId: that.broker.id | ||
}, nop) | ||
} | ||
} | ||
}) | ||
that.will = null // this function might be called twice |
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.
Removing this line here allows the function to be called twice. You should leave this line, and make an in-closure variable for that.will
.
lib/client.js
Outdated
@@ -258,7 +258,7 @@ Client.prototype.close = function (done) { | |||
} | |||
} | |||
}) | |||
that.will = null // this function might be called twice | |||
that._finished = true // this function might be called twice |
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.
a better solution is to extract that.will
into a variable, and keep that into the context of the closure.
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.
@mcollina Thanks you, sir!
test/will.js
Outdated
let authorized = false | ||
var opts = {} | ||
// willConnect populates opts with a will | ||
var s = willConnect(setup(aedes({ authorizePublish: (_1, _2, callback) => { authorized = true; setTimeout(() => { callback(null) }, 10) } })), opts) |
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.
Can you shorten up the line and use a setImmediate
instead?
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.
@mcollina Thanks you, sir!
…zePublish and use setImmediate instead of setTimeout in will test
Fixed for crash at comment