Skip to content

Commit fb0fa42

Browse files
committed
fix lgraph_cli exception
1 parent 0d55216 commit fb0fa42

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/bolt/pack_stream.h

+4
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ class PackStream {
221221
AppendStructMessage(BoltMsg::Ignored);
222222
}
223223

224+
void AppendReset() {
225+
AppendStructMessage(BoltMsg::Reset);
226+
}
227+
224228
void AppendFailure(const std::unordered_map<std::string, std::any>& meta) {
225229
AppendStructMessage(BoltMsg::Failure, meta);
226230
}

toolkits/lgraph_cli.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,23 @@ int main(int argc, char** argv) {
283283
asio::write(socket,
284284
asio::const_buffer(ps.ConstBuffer().data(), ps.ConstBuffer().size()));
285285
bool ret = FetchRecords(socket, hydrator, of);
286+
if (!ret) {
287+
// reset connection
288+
ps.Reset();
289+
ps.AppendReset();
290+
asio::write(socket,asio::const_buffer(ps.ConstBuffer().data(), ps.ConstBuffer().size()));
291+
while(true) {
292+
auto m = ReadMessage(socket, hydrator);
293+
if (m.type() == typeid(bolt::Success*)) {
294+
break;
295+
} else if (m.type() == typeid(bolt::Ignored*)) {
296+
continue;
297+
} else {
298+
LOG_ERROR() << "unexpected bolt msg after reset";
299+
return -1;
300+
}
301+
}
302+
}
286303
if (is_terminal && ret) {
287304
linenoiseHistoryAdd(statement.c_str());
288305
linenoiseHistorySave(history_file);

0 commit comments

Comments
 (0)