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

delivers a will waits for authorization #213

Merged
merged 4 commits into from
Aug 13, 2018

Conversation

nguyenthenguyen
Copy link
Contributor

Fixed for crash at comment

@nguyenthenguyen nguyenthenguyen mentioned this pull request Aug 13, 2018
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
Copy link
Contributor

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
Copy link
Collaborator

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.

Copy link
Contributor Author

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)
Copy link
Collaborator

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?

Copy link
Contributor Author

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
@mcollina mcollina merged commit 09f0070 into moscajs:master Aug 13, 2018
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.

3 participants