@intuned/runtime-dev 1.3.24-auth-issue.0 → 1.3.24-auth-issue.1
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/vendor/runtime-interface.js +15 -66
- package/package.json +1 -1
|
@@ -354,50 +354,35 @@ var require_interfaceClient = __commonJS({
|
|
|
354
354
|
var net = __importStar(require("net"));
|
|
355
355
|
var readline_1 = require("readline");
|
|
356
356
|
var promises_1 = require("timers/promises");
|
|
357
|
-
var util_1 = require("util");
|
|
358
357
|
var SocketClient = class _SocketClient {
|
|
359
358
|
constructor(socket) {
|
|
360
|
-
this.dataListener = null;
|
|
361
359
|
this.socket = socket;
|
|
362
|
-
this.closeAbortController = new AbortController();
|
|
363
360
|
}
|
|
364
|
-
|
|
365
|
-
if (this.socket.closed) {
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
361
|
+
sendJSON(data) {
|
|
368
362
|
const dataToSend = JSON.stringify(data);
|
|
369
363
|
const length = Buffer.byteLength(dataToSend);
|
|
370
364
|
const buffer = Buffer.alloc(_SocketClient.LENGTH_HEADER_LENGTH + length);
|
|
371
365
|
buffer.writeUInt32BE(length, 0);
|
|
372
366
|
buffer.write(dataToSend, _SocketClient.LENGTH_HEADER_LENGTH);
|
|
373
|
-
|
|
367
|
+
this.socket.write(buffer);
|
|
374
368
|
}
|
|
375
369
|
async *receiveJSON() {
|
|
376
370
|
let buffer = Buffer.alloc(0);
|
|
377
|
-
let endListener;
|
|
378
|
-
let rejectListener;
|
|
379
371
|
const endPromise = new Promise((resolve, reject) => {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
this.socket.once("error",
|
|
384
|
-
});
|
|
385
|
-
const closePromise = new Promise((resolve) => {
|
|
386
|
-
this.closeAbortController.signal.addEventListener("abort", () => resolve());
|
|
372
|
+
this.socket.once("end", () => {
|
|
373
|
+
resolve();
|
|
374
|
+
});
|
|
375
|
+
this.socket.once("error", reject);
|
|
387
376
|
});
|
|
388
377
|
while (true) {
|
|
389
378
|
const chunk = await Promise.race([
|
|
390
|
-
new Promise((resolve) => {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
this.socket.once("data", this.dataListener);
|
|
398
|
-
}),
|
|
399
|
-
endPromise,
|
|
400
|
-
closePromise
|
|
379
|
+
new Promise((resolve) => this.socket.once("data", (data2) => {
|
|
380
|
+
if (typeof data2 === "string") {
|
|
381
|
+
return resolve(Buffer.from(data2));
|
|
382
|
+
}
|
|
383
|
+
resolve(data2);
|
|
384
|
+
})),
|
|
385
|
+
endPromise
|
|
401
386
|
]);
|
|
402
387
|
if (!(chunk instanceof Buffer)) {
|
|
403
388
|
break;
|
|
@@ -418,44 +403,8 @@ var require_interfaceClient = __commonJS({
|
|
|
418
403
|
yield JSON.parse(data.toString());
|
|
419
404
|
}
|
|
420
405
|
}
|
|
421
|
-
async close(
|
|
422
|
-
|
|
423
|
-
if (this.dataListener) {
|
|
424
|
-
this.socket.off("data", this.dataListener);
|
|
425
|
-
console.log(`[${process.pid}] Removed data listener`);
|
|
426
|
-
} else {
|
|
427
|
-
console.log(`[${process.pid}] No data listener to remove`);
|
|
428
|
-
}
|
|
429
|
-
this.closeAbortController.abort();
|
|
430
|
-
console.log(`[${process.pid}] Called abort on closeAbortController`);
|
|
431
|
-
if (mode === "client") {
|
|
432
|
-
console.log(`[${process.pid}] Sending FIN to socket`);
|
|
433
|
-
await (0, util_1.promisify)((cb) => this.socket.end(cb))();
|
|
434
|
-
console.log(`[${process.pid}] Waiting for socket to close gracefully for 3 seconds...`);
|
|
435
|
-
const closeResult = await Promise.race([
|
|
436
|
-
new Promise((resolve) => this.socket.once("close", () => resolve("closed"))),
|
|
437
|
-
new Promise((resolve) => this.socket.once("error", () => resolve("error"))),
|
|
438
|
-
(0, promises_1.setTimeout)(3e3, "timeout")
|
|
439
|
-
]);
|
|
440
|
-
console.log(`[${process.pid}] Socket close result: ${closeResult}`);
|
|
441
|
-
if (closeResult === "timeout") {
|
|
442
|
-
console.warn(`[${process.pid}] Socket did not close within timeout, destroying socket`);
|
|
443
|
-
this.socket.destroy();
|
|
444
|
-
}
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
console.log(`[${process.pid}] Waiting for socket to end gracefully for 3 seconds...`);
|
|
448
|
-
const receiveEndResult = await Promise.race([
|
|
449
|
-
new Promise((resolve) => this.socket.once("end", () => resolve("end"))),
|
|
450
|
-
new Promise((resolve) => this.socket.once("error", () => resolve("error"))),
|
|
451
|
-
(0, promises_1.setTimeout)(3e3, "timeout")
|
|
452
|
-
]);
|
|
453
|
-
console.log(`[${process.pid}] Socket receive end result: ${receiveEndResult}`);
|
|
454
|
-
if (receiveEndResult === "end") {
|
|
455
|
-
console.log(`[${process.pid}] Socket ended gracefully`);
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
console.log(`[${process.pid}] Socket did not end gracefully, destroying socket`);
|
|
406
|
+
async close() {
|
|
407
|
+
this.socket.end();
|
|
459
408
|
this.socket.destroy();
|
|
460
409
|
}
|
|
461
410
|
get closed() {
|