socket-function 0.52.0 → 0.53.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.52.0",
3
+ "version": "0.53.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -167,7 +167,12 @@ export const runServerHooks = measureWrap(async function runServerHooks(
167
167
  ): Promise<HookContext> {
168
168
  let hookContext: HookContext = { call: callType, onResult: [] };
169
169
  for (let hook of globalHooks.concat(hooks.hooks || [])) {
170
+ let time = Date.now();
170
171
  await _setSocketContext(caller, () => hook(hookContext));
172
+ time = Date.now() - time;
173
+ if (time > 100) {
174
+ console.warn(`Slow (${formatTime(time)}) server hook: ${JSON.stringify(hook.name || hook.toString().slice(0, 100))} for ${callType.classGuid}.${callType.functionName}(...)`);
175
+ }
171
176
  // NOTE: See HookContext.overrideResult for why we don't break here
172
177
  }
173
178
  return hookContext;
@@ -75,6 +75,7 @@ export async function startSocketServer(
75
75
  ca: getTrustedCertificates(),
76
76
  // Attempt to disable sessions, because they make SNI significantly harder to parse.
77
77
  secureOptions: require("node:constants").SSL_OP_NO_TICKET,
78
+ keepAlive: false,
78
79
  };
79
80
  if (!httpsServerLast) {
80
81
  httpsServerLast = https.createServer(lastOptions);
@@ -192,6 +193,9 @@ export async function startSocketServer(
192
193
  //console.log("Received TCP connection from " + socket.remoteAddress);
193
194
  const remoteAddress = socket.remoteAddress;
194
195
  function handleTLSHello(buffer: Buffer, packetCount: number): void | "more" {
196
+ if (!SocketFunction.silent) {
197
+ console.log(`Received TCP header packet from ${remoteAddress}, have ${buffer.length} bytes so far, ${packetCount} packets`);
198
+ }
195
199
  // All HTTPS requests start with 22, and no HTTP requests start with 22,
196
200
  // so we just need to read the first byte.
197
201
  let server: https.Server | http.Server;