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

fix: done called twice on invalid options #667

Merged
merged 1 commit into from
Dec 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ C.open = function(allFields, openCallback0) {
function send(Method) {
// This can throw an exception if there's some problem with the
// options; e.g., something is a string instead of a number.
try { self.sendMethod(0, Method, tunedOptions); }
catch (err) { bail(err); }
self.sendMethod(0, Method, tunedOptions);
}

function negotiate(server, desired) {
Expand All @@ -205,7 +204,12 @@ C.open = function(allFields, openCallback0) {
return;
}
self.serverProperties = start.fields.serverProperties;
send(defs.ConnectionStartOk);
try {
send(defs.ConnectionStartOk);
} catch (err) {
bail(err);
return;
}
wait(afterStartOk);
}

Expand All @@ -227,8 +231,13 @@ C.open = function(allFields, openCallback0) {
negotiate(fields.channelMax, allFields.channelMax);
tunedOptions.heartbeat =
negotiate(fields.heartbeat, allFields.heartbeat);
send(defs.ConnectionTuneOk);
send(defs.ConnectionOpen);
try {
send(defs.ConnectionTuneOk);
send(defs.ConnectionOpen);
} catch (err) {
bail(err);
return;
}
expect(defs.ConnectionOpenOk, onOpenOk);
break;
default:
Expand Down