testdriverai 7.8.0-test.47 → 7.8.0-test.49
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/agent/lib/sandbox.js +20 -4
- package/package.json +1 -1
package/agent/lib/sandbox.js
CHANGED
|
@@ -61,8 +61,23 @@ const createSandbox = function (emitter, analytics, sessionInstance) {
|
|
|
61
61
|
var self = this;
|
|
62
62
|
|
|
63
63
|
this._ably = new Ably.Realtime({
|
|
64
|
-
authCallback: function (tokenParams, callback) {
|
|
65
|
-
|
|
64
|
+
authCallback: async function (tokenParams, callback) {
|
|
65
|
+
// On initial connect Ably may supply the token directly; on renewal
|
|
66
|
+
// we must fetch a fresh one from the API (the original token will
|
|
67
|
+
// have expired, causing 40143 token.unrecognized if reused).
|
|
68
|
+
try {
|
|
69
|
+
const response = await axios({
|
|
70
|
+
method: "post",
|
|
71
|
+
url: self.apiRoot + "/api/v7/sandbox/ably-token",
|
|
72
|
+
data: { apiKey: self.apiKey, sandboxId: self._sandboxId },
|
|
73
|
+
headers: { "Content-Type": "application/json" },
|
|
74
|
+
timeout: 15000,
|
|
75
|
+
});
|
|
76
|
+
callback(null, response.data.token);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
logger.warn("[ably] Token renewal failed, falling back to original token: " + (err.message || err));
|
|
79
|
+
callback(null, ablyToken);
|
|
80
|
+
}
|
|
66
81
|
},
|
|
67
82
|
clientId: "sdk-" + this._sandboxId,
|
|
68
83
|
echoMessages: false, // don't receive our own published messages
|
|
@@ -310,7 +325,7 @@ const createSandbox = function (emitter, analytics, sessionInstance) {
|
|
|
310
325
|
var reason = stateChange.reason;
|
|
311
326
|
var reasonMsg = reason ? (reason.message || reason.code || String(reason)) : '';
|
|
312
327
|
|
|
313
|
-
if (current === 'attached' && stateChange.resumed === false && previous) {
|
|
328
|
+
if (current === 'attached' && stateChange.resumed === false && previous === 'attached') {
|
|
314
329
|
logger.warn('[ably] Channel DISCONTINUITY detected (resumed=false)' + (reasonMsg ? ' — ' + reasonMsg : ''));
|
|
315
330
|
emitter.emit(events.sandbox.progress, {
|
|
316
331
|
step: 'discontinuity',
|
|
@@ -540,7 +555,8 @@ const createSandbox = function (emitter, analytics, sessionInstance) {
|
|
|
540
555
|
const needsReadyWait = this._sessionChannel && (isE2B || !reply.runner);
|
|
541
556
|
if (needsReadyWait) {
|
|
542
557
|
logger.log('Waiting for runner agent to signal readiness...');
|
|
543
|
-
|
|
558
|
+
// E2B (Linux) sandboxes need extra time: S3 upload + npm install can add 60-120s on top of sandbox boot
|
|
559
|
+
var readyTimeout = isE2B ? 300000 : 120000; // 5 min for E2B (S3+npm), 2 min for EC2
|
|
544
560
|
await new Promise(function (resolve, reject) {
|
|
545
561
|
var resolved = false;
|
|
546
562
|
function finish(data) {
|