socket-function 0.102.0 → 0.104.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "socket-function",
3
- "version": "0.102.0",
3
+ "version": "0.104.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -486,7 +486,7 @@ export async function createCallFactory(
486
486
  }
487
487
  if (SocketFunction.logMessages) {
488
488
  let call = callbackObj.call;
489
- console.log(`SIZE\t${(formatNumberSuffixed(resultSize) + "B").padEnd(4, " ")}\tRETURN\t${call.classGuid}.${call.functionName} at ${Date.now()}`);
489
+ console.log(`SIZE\t${(formatNumberSuffixed(resultSize) + "B").padEnd(4, " ")}\tRETURN\t${call.classGuid}.${call.functionName} at ${Date.now()}, (${nodeId} / ${localNodeId})`);
490
490
  }
491
491
  if (call.isResultCompressed) {
492
492
  call.result = await decompressObj(call.result as Buffer);
@@ -565,11 +565,15 @@ export async function createCallFactory(
565
565
  - The upgrade request finishes, at least once: Received websocket upgrade
566
566
  - AND, we are receiving some calls, so... that appears to work.
567
567
  - Maybe the time calls never finish?
568
+ - We added logging for when calls finish as well, so we can tell if all the TimeController calls timed out
569
+ - ALSO, added more logging to see if the calls were from the same client (which WOULD be a bug, because
570
+ the client shouldn't be calling us so often), or, different clients.
571
+ - We DO receive more connections than http connections closed. But not that many more...
568
572
  */
569
573
  console.log(red(`Call to ${call.classGuid}.${call.functionName} at ${Date.now()}`));
570
574
  }
571
575
  if (SocketFunction.logMessages) {
572
- console.log(`SIZE\t${(formatNumberSuffixed(resultSize) + "B").padEnd(4, " ")}\tEVALUATE\t${call.classGuid}.${call.functionName} at ${Date.now()}`);
576
+ console.log(`SIZE\t${(formatNumberSuffixed(resultSize) + "B").padEnd(4, " ")}\tEVALUATE\t${call.classGuid}.${call.functionName} at ${Date.now()}, (${nodeId} / ${localNodeId})`);
573
577
  }
574
578
  if (time > SocketFunction.WIRE_WARN_TIME) {
575
579
  console.log(red(`Slow parse, took ${time}ms to parse ${resultSize} bytes, for call to ${call.classGuid}.${call.functionName}`));
@@ -586,7 +590,7 @@ export async function createCallFactory(
586
590
  };
587
591
  if (SocketFunction.logMessages) {
588
592
  time = Date.now() - time;
589
- console.log(`DUR\t${(formatTime(time)).padEnd(6, " ")}\tFINISH\t${call.classGuid}.${call.functionName} at ${Date.now()}`);
593
+ console.log(`DUR\t${(formatTime(time)).padEnd(6, " ")}\tFINISH\t${call.classGuid}.${call.functionName} at ${Date.now()}, (${nodeId} / ${localNodeId})`);
590
594
  }
591
595
  if (shouldCompressCall(call)) {
592
596
  response.result = await compressObj(response.result) as any;
package/src/misc.ts CHANGED
@@ -445,3 +445,10 @@ export function timeoutToUndefinedSilent<T>(time: number, p: Promise<T>) {
445
445
  ).finally(() => clearTimeout(timeout));
446
446
  });
447
447
  }
448
+
449
+ export function errorToWarning<T>(promise: Promise<T>): Promise<T | undefined> {
450
+ return promise.catch(e => {
451
+ console.warn(e.stack);
452
+ return undefined as any;
453
+ });
454
+ }
@@ -261,6 +261,11 @@ export async function startSocketServer(
261
261
  socket.on("error", (e) => {
262
262
  console.error(`TCP socket error for ${debug}, ${e.stack}`);
263
263
  });
264
+ socket.on("close", () => {
265
+ if (!SocketFunction.silent) {
266
+ console.log(`TCP socket closed for ${debug}`);
267
+ }
268
+ });
264
269
  });
265
270
 
266
271