@adhdev/session-host-core 1.0.82-rc.27 → 1.0.82-rc.29
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/dist/index.d.mts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +47 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/ipc.ts +46 -3
- package/src/types.ts +11 -0
package/dist/index.mjs
CHANGED
|
@@ -16,6 +16,7 @@ var SESSION_HOST_SUPPORTED_REQUEST_TYPES = [
|
|
|
16
16
|
"send_input",
|
|
17
17
|
"resize_session",
|
|
18
18
|
"stop_session",
|
|
19
|
+
"stop_mesh_writer",
|
|
19
20
|
"delete_session",
|
|
20
21
|
"resume_session",
|
|
21
22
|
"acquire_write",
|
|
@@ -856,9 +857,24 @@ var SessionHostClient = class {
|
|
|
856
857
|
request
|
|
857
858
|
};
|
|
858
859
|
const timeoutLabel = timeoutMs % 1e3 === 0 ? `${timeoutMs / 1e3}s` : `${timeoutMs}ms`;
|
|
860
|
+
const startedAt = Date.now();
|
|
861
|
+
const startedMonotonicAt = performance.now();
|
|
859
862
|
return new Promise((resolve3, reject) => {
|
|
860
863
|
const timeout = setTimeout(() => {
|
|
861
|
-
const
|
|
864
|
+
const actualElapsedMs = Math.max(0, Math.round(performance.now() - startedMonotonicAt));
|
|
865
|
+
const wallElapsedMs = Math.max(0, Date.now() - startedAt);
|
|
866
|
+
const observerLagMs = Math.max(0, actualElapsedMs - timeoutMs);
|
|
867
|
+
const timeoutError = Object.assign(
|
|
868
|
+
new Error(`Session host request timed out after ${timeoutLabel} (${request.type})`),
|
|
869
|
+
{
|
|
870
|
+
code: "SESSION_HOST_REQUEST_TIMEOUT",
|
|
871
|
+
requestType: request.type,
|
|
872
|
+
scheduledTimeoutMs: timeoutMs,
|
|
873
|
+
actualElapsedMs,
|
|
874
|
+
wallElapsedMs,
|
|
875
|
+
observerLagMs
|
|
876
|
+
}
|
|
877
|
+
);
|
|
862
878
|
if (this.socket === socket) {
|
|
863
879
|
this.disconnect(timeoutError);
|
|
864
880
|
} else {
|
|
@@ -948,8 +964,22 @@ var SessionHostClient = class {
|
|
|
948
964
|
reject(error);
|
|
949
965
|
};
|
|
950
966
|
const closed = () => failed(new Error("Session host connection closed before connect"));
|
|
967
|
+
const connectStartedAt = Date.now();
|
|
968
|
+
const connectStartedMonotonicAt = performance.now();
|
|
951
969
|
const timer = setTimeout(() => {
|
|
952
|
-
const
|
|
970
|
+
const actualElapsedMs = Math.max(0, Math.round(performance.now() - connectStartedMonotonicAt));
|
|
971
|
+
const wallElapsedMs = Math.max(0, Date.now() - connectStartedAt);
|
|
972
|
+
const observerLagMs = Math.max(0, actualElapsedMs - timeoutMs);
|
|
973
|
+
const error = Object.assign(
|
|
974
|
+
new Error(`Session host connect timed out after ${timeoutMs}ms`),
|
|
975
|
+
{
|
|
976
|
+
code: "SESSION_HOST_CONNECT_TIMEOUT",
|
|
977
|
+
scheduledTimeoutMs: timeoutMs,
|
|
978
|
+
actualElapsedMs,
|
|
979
|
+
wallElapsedMs,
|
|
980
|
+
observerLagMs
|
|
981
|
+
}
|
|
982
|
+
);
|
|
953
983
|
failed(error);
|
|
954
984
|
if (this.socket === socket) this.disconnect(error);
|
|
955
985
|
}, timeoutMs);
|
|
@@ -991,12 +1021,26 @@ var SessionHostClient = class {
|
|
|
991
1021
|
const alreadyConnected = this.isConnected() && !this.connectPromise;
|
|
992
1022
|
if (options.timeoutMs !== void 0) {
|
|
993
1023
|
let timer;
|
|
1024
|
+
const raceStartedAt = Date.now();
|
|
1025
|
+
const raceStartedMonotonicAt = performance.now();
|
|
994
1026
|
try {
|
|
995
1027
|
await Promise.race([
|
|
996
1028
|
this.connect(timeoutMs),
|
|
997
1029
|
new Promise((_resolve, reject) => {
|
|
998
1030
|
timer = setTimeout(() => {
|
|
999
|
-
const
|
|
1031
|
+
const actualElapsedMs = Math.max(0, Math.round(performance.now() - raceStartedMonotonicAt));
|
|
1032
|
+
const wallElapsedMs = Math.max(0, Date.now() - raceStartedAt);
|
|
1033
|
+
const observerLagMs = Math.max(0, actualElapsedMs - timeoutMs);
|
|
1034
|
+
const error = Object.assign(
|
|
1035
|
+
new Error(`Session host connect timed out after ${timeoutMs}ms`),
|
|
1036
|
+
{
|
|
1037
|
+
code: "SESSION_HOST_CONNECT_TIMEOUT",
|
|
1038
|
+
scheduledTimeoutMs: timeoutMs,
|
|
1039
|
+
actualElapsedMs,
|
|
1040
|
+
wallElapsedMs,
|
|
1041
|
+
observerLagMs
|
|
1042
|
+
}
|
|
1043
|
+
);
|
|
1000
1044
|
reject(error);
|
|
1001
1045
|
this.disconnect(error);
|
|
1002
1046
|
}, timeoutMs);
|