Skip to content

Commit

Permalink
fix lgraph_cli exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ljcui committed Oct 9, 2024
1 parent 0d55216 commit fb0fa42
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bolt/pack_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ class PackStream {
AppendStructMessage(BoltMsg::Ignored);
}

void AppendReset() {
AppendStructMessage(BoltMsg::Reset);
}

void AppendFailure(const std::unordered_map<std::string, std::any>& meta) {
AppendStructMessage(BoltMsg::Failure, meta);
}
Expand Down
17 changes: 17 additions & 0 deletions toolkits/lgraph_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,23 @@ int main(int argc, char** argv) {
asio::write(socket,
asio::const_buffer(ps.ConstBuffer().data(), ps.ConstBuffer().size()));
bool ret = FetchRecords(socket, hydrator, of);
if (!ret) {
// reset connection
ps.Reset();
ps.AppendReset();
asio::write(socket,asio::const_buffer(ps.ConstBuffer().data(), ps.ConstBuffer().size()));
while(true) {
auto m = ReadMessage(socket, hydrator);
if (m.type() == typeid(bolt::Success*)) {
break;
} else if (m.type() == typeid(bolt::Ignored*)) {
continue;
} else {
LOG_ERROR() << "unexpected bolt msg after reset";
return -1;
}
}
}
if (is_terminal && ret) {
linenoiseHistoryAdd(statement.c_str());
linenoiseHistorySave(history_file);
Expand Down

0 comments on commit fb0fa42

Please sign in to comment.