socket-function 0.100.0 → 0.102.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.100.0",
3
+ "version": "0.102.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -499,6 +499,73 @@ export async function createCallFactory(
499
499
  call.isArgsCompressed = false;
500
500
  }
501
501
  if (call.functionName === "changeIdentity") {
502
+ /*
503
+ TODO: Sometimes calls don't get through, even though we know the client made the call. Here are the logs from a failing case:
504
+ Exposing Controller ServerController-17ea53da-bbef-4c8b-9eb0-99e263464c6f
505
+ Exposing Controller HotReloadController-032b2250-3aac-4187-8c95-75412742b8f5
506
+ Exposing Controller TimeController-ddf4753e-fc8a-413f-8cc2-b927dd449976
507
+ Updating websocket server options
508
+ Updating websocket server trusted certificates
509
+ Updating websocket server options
510
+ Updating websocket server trusted certificates
511
+ Updating websocket server options
512
+ Updating websocket server trusted certificates
513
+ Trying to listening on 127.0.0.1:4231
514
+ Started Listening on planquickly.com:4231 (127.0.0.1) after 5.54s
515
+ Mounted on 127-0-0-1.planquickly.com:4231
516
+ Exposing Controller RequireController-e2f811f3-14b8-4759-b0d6-73f14516cf1d
517
+ Received TCP connection from 127.0.0.1:42105
518
+ Received TCP header packet from 127.0.0.1:42105, have 1894 bytes so far, 1 packets
519
+ Received TCP connection with SNI "127-0-0-1.planquickly.com". Have handlers for: planquickly.com, 127-0-0-1.planquickly.com
520
+ HTTP server connection established 127.0.0.1:42105
521
+ HTTP request (GET) https://127-0-0-1.planquickly.com:4231/?hot
522
+ HTTP response 106KB (GET) https://127-0-0-1.planquickly.com:4231/?hot
523
+ HTTP server socket closed for 127.0.0.1:42105
524
+ Received TCP connection from 127.0.0.1:42106
525
+ Received TCP header packet from 127.0.0.1:42106, have 1862 bytes so far, 1 packets
526
+ Received TCP connection with SNI "127-0-0-1.planquickly.com". Have handlers for: planquickly.com, 127-0-0-1.planquickly.com
527
+ HTTP server connection established 127.0.0.1:42106
528
+ HTTP request (GET) https://127-0-0-1.planquickly.com:4231/?classGuid=RequireController-e2f811f3-14b8-4759-b0d6-73f14516cf1d&functionName=getModules&args=%5B%5B%22.%2Fsite%2FsiteMain%22%5D%2Cnull%5D
529
+ HTTP response 10.8MB (GET) https://127-0-0-1.planquickly.com:4231/?classGuid=RequireController-e2f811f3-14b8-4759-b0d6-73f14516cf1d&functionName=getModules&args=%5B%5B%22.%2Fsite%2FsiteMain%22%5D%2Cnull%5D
530
+ Received TCP connection from 127.0.0.1:42107
531
+ Received TCP header packet from 127.0.0.1:42107, have 1894 bytes so far, 1 packets
532
+ Received TCP connection with SNI "127-0-0-1.planquickly.com". Have handlers for: planquickly.com, 127-0-0-1.planquickly.com
533
+ HTTP server connection established 127.0.0.1:42107
534
+ HTTP server socket closed for 127.0.0.1:42106
535
+ HTTP server socket closed for 127.0.0.1:42107
536
+ Received TCP connection from 127.0.0.1:42108
537
+ Received TCP header packet from 127.0.0.1:42108, have 1830 bytes so far, 1 packets
538
+ Received TCP connection with SNI "127-0-0-1.planquickly.com". Have handlers for: planquickly.com, 127-0-0-1.planquickly.com
539
+ HTTP server connection established 127.0.0.1:42108
540
+ HTTP request (GET) https://127-0-0-1.planquickly.com:4231/node.cjs.map
541
+ HTTP response 106KB (GET) https://127-0-0-1.planquickly.com:4231/node.cjs.map
542
+ HTTP server socket closed for 127.0.0.1:42108
543
+ Received TCP connection from 127.0.0.1:42110
544
+ Received TCP header packet from 127.0.0.1:42110, have 1818 bytes so far, 1 packets
545
+ Received TCP connection with SNI "127-0-0-1.planquickly.com". Have handlers for: planquickly.com, 127-0-0-1.planquickly.com
546
+ HTTP server connection established 127.0.0.1:42110
547
+ Received TCP connection from 127.0.0.1:42111
548
+ Received TCP header packet from 127.0.0.1:42111, have 1830 bytes so far, 1 packets
549
+ Received TCP connection with SNI "127-0-0-1.planquickly.com". Have handlers for: planquickly.com, 127-0-0-1.planquickly.com
550
+ HTTP server connection established 127.0.0.1:42111
551
+ Received websocket upgrade request for 127.0.0.1:42110
552
+ Connection established to client:127.0.0.1:1744150129862.296:0.4118126921519041
553
+ HTTP request (GET) https://127-0-0-1.planquickly.com:4231/?classGuid=RequireController-e2f811f3-14b8-4759-b0d6-73f14516cf1d&functionName=getModules&args=%5B%5B%22D%3A%2Frepos%2Fperspectanalytics%2Fai3%2Fnode_modules%2Fsocket-function%2Ftime%2FtrueTimeShim.ts%22%5D%2C%7B%22requireSeqNumProcessId%22%3A%22requireSeqNumProcessId_1744150120269_0.5550074391586426%22%2C%22seqNumRanges%22%3A%5B%7B%22s%22%3A1%2C%22e%22%3A892%7D%5D%7D%5D
554
+ HTTP response 31.1KB (GET) https://127-0-0-1.planquickly.com:4231/?classGuid=RequireController-e2f811f3-14b8-4759-b0d6-73f14516cf1d&functionName=getModules&args=%5B%5B%22D%3A%2Frepos%2Fperspectanalytics%2Fai3%2Fnode_modules%2Fsocket-function%2Ftime%2FtrueTimeShim.ts%22%5D%2C%7B%22requireSeqNumProcessId%22%3A%22requireSeqNumProcessId_1744150120269_0.5550074391586426%22%2C%22seqNumRanges%22%3A%5B%7B%22s%22%3A1%2C%22e%22%3A892%7D%5D%7D%5D
555
+ SIZE 171B EVALUATE HotReloadController-032b2250-3aac-4187-8c95-75412742b8f5.watchFiles at 1744150129869.296
556
+ SIZE 174B EVALUATE ServerController-17ea53da-bbef-4c8b-9eb0-99e263464c6f.testSiteFunction at 1744150129872.296
557
+ HTTP server socket closed for 127.0.0.1:42111
558
+ SIZE 167B EVALUATE TimeController-ddf4753e-fc8a-413f-8cc2-b927dd449976.getTrueTime at 1744150129893.296
559
+ SIZE 167B EVALUATE TimeController-ddf4753e-fc8a-413f-8cc2-b927dd449976.getTrueTime at 1744150129897.296
560
+ SIZE 167B EVALUATE TimeController-ddf4753e-fc8a-413f-8cc2-b927dd449976.getTrueTime at 1744150129899.296
561
+ SIZE 167B EVALUATE TimeController-ddf4753e-fc8a-413f-8cc2-b927dd449976.getTrueTime at 1744150139907.0776
562
+ SIZE 167B EVALUATE TimeController-ddf4753e-fc8a-413f-8cc2-b927dd449976.getTrueTime at 1744150139909.0776
563
+ SIZE 167B EVALUATE TimeController-ddf4753e-fc8a-413f-8cc2-b927dd449976.getTrueTime at 1744150139911.0776
564
+ Hot reloading due to change: D:/repos/perspectanalytics/ai3/node_modules/socket-function/src/webSocketServer.ts
565
+ - The upgrade request finishes, at least once: Received websocket upgrade
566
+ - AND, we are receiving some calls, so... that appears to work.
567
+ - Maybe the time calls never finish?
568
+ */
502
569
  console.log(red(`Call to ${call.classGuid}.${call.functionName} at ${Date.now()}`));
503
570
  }
504
571
  if (SocketFunction.logMessages) {
@@ -510,12 +577,17 @@ export async function createCallFactory(
510
577
 
511
578
  let response: InternalReturnType;
512
579
  try {
580
+ let time = Date.now();
513
581
  let result = await performLocalCall({ call, caller: callerContext });
514
582
  response = {
515
583
  isReturn: true,
516
584
  result,
517
585
  seqNum: call.seqNum,
518
586
  };
587
+ if (SocketFunction.logMessages) {
588
+ time = Date.now() - time;
589
+ console.log(`DUR\t${(formatTime(time)).padEnd(6, " ")}\tFINISH\t${call.classGuid}.${call.functionName} at ${Date.now()}`);
590
+ }
519
591
  if (shouldCompressCall(call)) {
520
592
  response.result = await compressObj(response.result) as any;
521
593
  response.isResultCompressed = true;
@@ -80,7 +80,8 @@ export async function startSocketServer(
80
80
  };
81
81
  if (!httpsServerLast) {
82
82
  httpsServerLast = https.createServer(lastOptions);
83
- // We REALLY don't want keep alive, at all, as keep alives break so many things.
83
+ // NOTE: This MIGHT be different than the keep alive option? Probably not, but also...
84
+ // something weird is happening with connections...
84
85
  httpsServerLast.keepAliveTimeout = 0;
85
86
  } else {
86
87
  httpsServerLast.setSecureContext(lastOptions);
@@ -167,6 +168,8 @@ export async function startSocketServer(
167
168
  // our websockets, so... we really don't need to keep alive our HTTP requests
168
169
  // (and our images go through cloudflare, so we don't even need keep alive for that)
169
170
  keepAlive: false,
171
+ keepAliveInitialDelay: 0,
172
+ noDelay: true,
170
173
  };
171
174
  if (!config.cert) {
172
175
  throw new Error("No cert specified");
@@ -181,7 +184,7 @@ export async function startSocketServer(
181
184
  sniServers.set(domain, await setupHTTPSServer(obj));
182
185
  }
183
186
 
184
- let httpServer = http.createServer({}, async function (req, res) {
187
+ let httpServer = http.createServer({ keepAlive: false, }, async function (req, res) {
185
188
  let url = new URL("http://" + req.headers.host + req.url);
186
189
  url.protocol = "https:";
187
190
  //url.hostname = opts.hostname;
@@ -189,6 +192,7 @@ export async function startSocketServer(
189
192
  res.writeHead(301, { Location: url + "" });
190
193
  res.end();
191
194
  });
195
+ httpServer.keepAliveTimeout = 0;
192
196
  httpServer.on("error", e => {
193
197
  console.error(`HTTP error ${e.stack}`);
194
198
  });