neurondb 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/app.js +31 -2
- package/src/config.js +1 -1
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -87,6 +87,7 @@ export async function main() {
|
|
|
87
87
|
homeDir,
|
|
88
88
|
running: true,
|
|
89
89
|
polling: false, // guard against concurrent polls
|
|
90
|
+
offline: false, // track server connectivity
|
|
90
91
|
bashTimeout,
|
|
91
92
|
pollTimer: null,
|
|
92
93
|
heartbeatTimer: null,
|
|
@@ -96,7 +97,8 @@ export async function main() {
|
|
|
96
97
|
|
|
97
98
|
// Re-register session after auto-reconnect (server restart clears tokens + sessions)
|
|
98
99
|
api.onReconnect(async () => {
|
|
99
|
-
|
|
100
|
+
state.offline = false;
|
|
101
|
+
printRemote('Server reconnected — re-registering session...');
|
|
100
102
|
const meta = JSON.stringify({
|
|
101
103
|
connected_at: new Date().toISOString(),
|
|
102
104
|
hostname: os.hostname(),
|
|
@@ -180,7 +182,19 @@ async function handleInput(state, input) {
|
|
|
180
182
|
// Execute SNL on server
|
|
181
183
|
try {
|
|
182
184
|
const result = await state.api.snl(input);
|
|
183
|
-
|
|
185
|
+
if (result.raw && result.raw.message && result.raw.message.includes('Connection error')) {
|
|
186
|
+
if (!state.offline) {
|
|
187
|
+
state.offline = true;
|
|
188
|
+
printRemote('Server offline — waiting for reconnect...');
|
|
189
|
+
}
|
|
190
|
+
printErrorOutput('Server unreachable. Command not executed.');
|
|
191
|
+
} else {
|
|
192
|
+
if (state.offline) {
|
|
193
|
+
state.offline = false;
|
|
194
|
+
printRemote('Server back online');
|
|
195
|
+
}
|
|
196
|
+
printResult(result);
|
|
197
|
+
}
|
|
184
198
|
} catch (err) {
|
|
185
199
|
printErrorOutput(`Execution error: ${err.message}`);
|
|
186
200
|
}
|
|
@@ -196,6 +210,21 @@ async function pollPending(state) {
|
|
|
196
210
|
const snl = `GET() ON(${pendingPath}) GO()`;
|
|
197
211
|
const result = await state.api.snl(snl);
|
|
198
212
|
|
|
213
|
+
// Detect connection errors → mark offline
|
|
214
|
+
if (result.raw && result.raw.message && result.raw.message.includes('Connection error')) {
|
|
215
|
+
if (!state.offline) {
|
|
216
|
+
state.offline = true;
|
|
217
|
+
printRemote('Server offline — waiting for reconnect...');
|
|
218
|
+
}
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Back online
|
|
223
|
+
if (state.offline) {
|
|
224
|
+
state.offline = false;
|
|
225
|
+
printRemote('Server back online');
|
|
226
|
+
}
|
|
227
|
+
|
|
199
228
|
if (!result.success || !result.data) return;
|
|
200
229
|
|
|
201
230
|
// Parse queue — can be array or single object (legacy)
|