socket-function 1.2.32 → 1.2.34
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/callHTTPHandler.ts +13 -4
- package/src/callManager.ts +2 -1
package/package.json
CHANGED
package/src/callHTTPHandler.ts
CHANGED
|
@@ -146,9 +146,14 @@ export async function httpCallHandler(request: http.IncomingMessage, response: h
|
|
|
146
146
|
|
|
147
147
|
let protocol = "https";
|
|
148
148
|
let url = protocol + "://" + request.headers.host + request.url;
|
|
149
|
+
let loggingURL = url;
|
|
150
|
+
try {
|
|
151
|
+
loggingURL = new URL(urlBase).origin;
|
|
152
|
+
} catch { }
|
|
153
|
+
|
|
149
154
|
|
|
150
155
|
if (SocketFunction.logMessages) {
|
|
151
|
-
console.log(`HTTP request (${request.method}) ${
|
|
156
|
+
console.log(`HTTP request (${request.method}) ${loggingURL}`);
|
|
152
157
|
}
|
|
153
158
|
let urlObj = new URL(url);
|
|
154
159
|
|
|
@@ -216,7 +221,9 @@ export async function httpCallHandler(request: http.IncomingMessage, response: h
|
|
|
216
221
|
response.setHeader("ETag", hash);
|
|
217
222
|
if (request.headers["if-none-match"] === hash) {
|
|
218
223
|
response.writeHead(304);
|
|
219
|
-
|
|
224
|
+
if (SocketFunction.logMessages) {
|
|
225
|
+
console.log(`CACHED Immutable HTTP response (${request.method}) ${loggingURL}`);
|
|
226
|
+
}
|
|
220
227
|
return;
|
|
221
228
|
}
|
|
222
229
|
}
|
|
@@ -249,7 +256,9 @@ export async function httpCallHandler(request: http.IncomingMessage, response: h
|
|
|
249
256
|
response.setHeader("ETag", hash);
|
|
250
257
|
if (request.headers["if-none-match"] === hash) {
|
|
251
258
|
response.writeHead(304);
|
|
252
|
-
|
|
259
|
+
if (SocketFunction.logMessages) {
|
|
260
|
+
console.log(`CACHED HTTP response ${formatNumberSuffixed(resultBuffer.length)}B (${request.method}) ${loggingURL}`);
|
|
261
|
+
}
|
|
253
262
|
return;
|
|
254
263
|
}
|
|
255
264
|
}
|
|
@@ -297,7 +306,7 @@ export async function httpCallHandler(request: http.IncomingMessage, response: h
|
|
|
297
306
|
}
|
|
298
307
|
response.write(resultBuffer);
|
|
299
308
|
if (SocketFunction.logMessages) {
|
|
300
|
-
console.log(`HTTP response ${formatNumberSuffixed(resultBuffer.length)}B (${request.method}) ${
|
|
309
|
+
console.log(`HTTP response ${formatNumberSuffixed(resultBuffer.length)}B (${request.method}) ${loggingURL}`);
|
|
301
310
|
}
|
|
302
311
|
|
|
303
312
|
} catch (e: any) {
|
package/src/callManager.ts
CHANGED
|
@@ -129,7 +129,8 @@ export function unregisterGlobalClientHook(hook: SocketFunctionClientHook) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
let startupTime = Date.now();
|
|
132
|
-
|
|
132
|
+
// NOTE: We don't time run client hooks as some of the hooks want to be not measured. And if we time the parent function, then they can't be not measured.
|
|
133
|
+
export const runClientHooks = (async function runClientHooks(
|
|
133
134
|
callType: FullCallType,
|
|
134
135
|
hooks: Exclude<SocketExposedShape[""], undefined>,
|
|
135
136
|
connectionId: { nodeId: string },
|