socket-function 1.2.30 → 1.2.31
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/SocketFunctionTypes.d.ts +4 -0
- package/SocketFunctionTypes.ts +4 -0
- package/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/callManager.ts +6 -2
package/SocketFunctionTypes.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ export type ClientHookContext = {
|
|
|
62
62
|
};
|
|
63
63
|
export interface SocketFunctionClientHook {
|
|
64
64
|
(config: ClientHookContext): MaybePromise<void>;
|
|
65
|
+
/** Set on hooks which are called so frequently (or are so trivial) that the measurement overhead
|
|
66
|
+
* and profiling noise outweighs the value of measuring them.
|
|
67
|
+
*/
|
|
68
|
+
noMeasure?: boolean;
|
|
65
69
|
}
|
|
66
70
|
export interface SocketRegisterType<ExposedType = any> {
|
|
67
71
|
_classGuid: string;
|
package/SocketFunctionTypes.ts
CHANGED
|
@@ -92,6 +92,10 @@ export type ClientHookContext = {
|
|
|
92
92
|
};
|
|
93
93
|
export interface SocketFunctionClientHook {
|
|
94
94
|
(config: ClientHookContext): MaybePromise<void>;
|
|
95
|
+
/** Set on hooks which are called so frequently (or are so trivial) that the measurement overhead
|
|
96
|
+
* and profiling noise outweighs the value of measuring them.
|
|
97
|
+
*/
|
|
98
|
+
noMeasure?: boolean;
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
export interface SocketRegisterType<ExposedType = any> {
|
package/index.d.ts
CHANGED
|
@@ -194,6 +194,10 @@ declare module "socket-function/SocketFunctionTypes" {
|
|
|
194
194
|
};
|
|
195
195
|
export interface SocketFunctionClientHook {
|
|
196
196
|
(config: ClientHookContext): MaybePromise<void>;
|
|
197
|
+
/** Set on hooks which are called so frequently (or are so trivial) that the measurement overhead
|
|
198
|
+
* and profiling noise outweighs the value of measuring them.
|
|
199
|
+
*/
|
|
200
|
+
noMeasure?: boolean;
|
|
197
201
|
}
|
|
198
202
|
export interface SocketRegisterType<ExposedType = any> {
|
|
199
203
|
_classGuid: string;
|
package/package.json
CHANGED
package/src/callManager.ts
CHANGED
|
@@ -147,9 +147,13 @@ export const runClientHooks = measureWrap(async function runClientHooks(
|
|
|
147
147
|
}
|
|
148
148
|
for (let hook of clientHooks) {
|
|
149
149
|
let time = Date.now();
|
|
150
|
-
|
|
150
|
+
if (hook.noMeasure) {
|
|
151
151
|
await hook(context);
|
|
152
|
-
}
|
|
152
|
+
} else {
|
|
153
|
+
await measureBlock(async () => {
|
|
154
|
+
await hook(context);
|
|
155
|
+
}, `clientHook|${hook.name || hook.toString().slice(0, 100)}`);
|
|
156
|
+
}
|
|
153
157
|
let now = Date.now();
|
|
154
158
|
time = now - time;
|
|
155
159
|
if (time > 500 && now - startupTime > 60_000) {
|