socket-function 0.51.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.51.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",
@@ -4,6 +4,7 @@ import { _setSocketContext } from "../SocketFunction";
4
4
  import { entries, isNode } from "./misc";
5
5
  import debugbreak from "debugbreak";
6
6
  import { measureWrap } from "./profiling/measure";
7
+ import { formatTime } from "./formatting/format";
7
8
 
8
9
  let classes: {
9
10
  [classGuid: string]: {
@@ -148,7 +149,7 @@ export const runClientHooks = measureWrap(async function runClientHooks(
148
149
  await hook(context);
149
150
  time = Date.now() - time;
150
151
  if (time > 100) {
151
- console.warn(`Slow client hook: ${JSON.stringify(hook.name || hook.toString().slice(0, 100))} took ${time}ms`);
152
+ console.warn(`Slow (${formatTime(time)}) client hook: ${JSON.stringify(hook.name || hook.toString().slice(0, 100))} for ${callType.classGuid}.${callType.functionName}(...)`);
152
153
  }
153
154
  // NOTE: See ClientHookContext.overrideResult for why we break here
154
155
  if ("overrideResult" in context) {
@@ -166,7 +167,12 @@ export const runServerHooks = measureWrap(async function runServerHooks(
166
167
  ): Promise<HookContext> {
167
168
  let hookContext: HookContext = { call: callType, onResult: [] };
168
169
  for (let hook of globalHooks.concat(hooks.hooks || [])) {
170
+ let time = Date.now();
169
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
+ }
170
176
  // NOTE: See HookContext.overrideResult for why we don't break here
171
177
  }
172
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;