socket-function 0.127.0 → 0.129.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/SocketFunction.ts +2 -0
- package/package.json +1 -1
- package/src/callHTTPHandler.ts +1 -1
- package/src/misc.ts +0 -1
- package/src/profiling/getOwnTime.ts +1 -4
- package/src/profiling/measure.ts +8 -1
package/SocketFunction.ts
CHANGED
|
@@ -63,6 +63,8 @@ export class SocketFunction {
|
|
|
63
63
|
// If you have HTTP resources that require cookies you might to set `SocketFunction.COEP = "require-corp"`
|
|
64
64
|
// - Cross-origin-resource-policy.
|
|
65
65
|
public static COEP = "credentialless";
|
|
66
|
+
// NOTE: This COOP and COEP defaults are required so window.crossOriginIsolated will be true.
|
|
67
|
+
public static COOP = "same-origin";
|
|
66
68
|
|
|
67
69
|
// In retrospect... dynamically changing the wire serializer is a BAD idea. If any calls happen
|
|
68
70
|
// before it is changed, things just break. Also, it needs to be changed on both sides,
|
package/package.json
CHANGED
package/src/callHTTPHandler.ts
CHANGED
|
@@ -64,7 +64,7 @@ export async function httpCallHandler(request: http.IncomingMessage, response: h
|
|
|
64
64
|
// CORS bs (due to having to explictly allow subdomains)
|
|
65
65
|
{
|
|
66
66
|
response.setHeader("Strict-Transport-Security", "max-age=63072000; includeSubDomains; preload");
|
|
67
|
-
response.setHeader("Cross-Origin-Opener-Policy",
|
|
67
|
+
response.setHeader("Cross-Origin-Opener-Policy", SocketFunction.COOP);
|
|
68
68
|
response.setHeader("Cross-Origin-Embedder-Policy", SocketFunction.COEP);
|
|
69
69
|
|
|
70
70
|
let origin = request.headers.origin || request.headers.referer;
|
package/src/misc.ts
CHANGED
|
@@ -196,7 +196,6 @@ export function promiseObj<T = void>(): PromiseObj<T> {
|
|
|
196
196
|
return new PromiseObj<T>();
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
|
|
200
199
|
// Allows an immediate call, then delays the next call until the first call finishes + delay
|
|
201
200
|
// - Drops all but the latest call, but only resolves the promises return to all
|
|
202
201
|
// calls once the latest call finishes.
|
|
@@ -3,10 +3,7 @@ import { isNode } from "../misc";
|
|
|
3
3
|
// TODO: We could probably make this an optional / dev dependency, to allow
|
|
4
4
|
// for use on machines without the ability to compile?
|
|
5
5
|
//import { now } from "rdtsc-now";
|
|
6
|
-
let now = () =>
|
|
7
|
-
if (isNode()) {
|
|
8
|
-
now = () => performance.now();
|
|
9
|
-
}
|
|
6
|
+
let now = () => performance.now();
|
|
10
7
|
|
|
11
8
|
export type OwnTimeObj = {
|
|
12
9
|
name: string;
|
package/src/profiling/measure.ts
CHANGED
|
@@ -86,6 +86,9 @@ export function registerMeasureInfo(getInfo: () => string | undefined) {
|
|
|
86
86
|
extraInfoGetters.push(getInfo);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/** IMPORTANT! Always finish the profile! If you don't, you will leak A LOT of memory
|
|
90
|
+
* (you leak all future measures, PER unfinished profile)!
|
|
91
|
+
*/
|
|
89
92
|
export function startMeasure(): {
|
|
90
93
|
finish: () => MeasureProfile;
|
|
91
94
|
} {
|
|
@@ -101,6 +104,9 @@ export function startMeasure(): {
|
|
|
101
104
|
let openAtStart = new Set(getOpenTimesBase());
|
|
102
105
|
|
|
103
106
|
outstandingProfiles.push(profile);
|
|
107
|
+
if (outstandingProfiles.length > 1000) {
|
|
108
|
+
console.warn(red(`You have ${outstandingProfiles.length} outstanding startMeasure calls. You are probably leaking them!`));
|
|
109
|
+
}
|
|
104
110
|
return {
|
|
105
111
|
finish() {
|
|
106
112
|
let pending = getOpenTimesBase();
|
|
@@ -201,7 +207,7 @@ export function logMeasureTable(
|
|
|
201
207
|
process.stdout.write(`\x1b]0;${title}\x07`);
|
|
202
208
|
}
|
|
203
209
|
let pid = isNode() ? `(${process.pid}) ` : "";
|
|
204
|
-
let title = yellow(`${pid}Profiled ${formatTime(totalTime)} (${percent(fraction)} CPU)${extraInfos.map(x => x ? ` (${x})` : "")} (logged at ${new Date().toISOString()}, profile for ${formatTime(timeRunFor)})`);
|
|
210
|
+
let title = yellow(`${pid}Profiled ${formatTime(totalTime)} (${percent(fraction)} CPU)${extraInfos.map(x => x ? ` (${x})` : "").filter(x => x).join(" |")} (logged at ${new Date().toISOString()}, profile for ${formatTime(timeRunFor)})`);
|
|
205
211
|
if (name) {
|
|
206
212
|
title = `(${blue(name)}) ${title}`;
|
|
207
213
|
}
|
|
@@ -349,6 +355,7 @@ interface ProfileEntry {
|
|
|
349
355
|
let measurementsEnabled = true;
|
|
350
356
|
|
|
351
357
|
let outstandingProfiles: MeasureProfile[] = [];
|
|
358
|
+
(globalThis as any).outstandingProfiles = outstandingProfiles;
|
|
352
359
|
function recordOwnTime(ownTimeObj: OwnTimeObj) {
|
|
353
360
|
if (outstandingProfiles.length === 0) return;
|
|
354
361
|
for (let i = 0; i < outstandingProfiles.length; i++) {
|