@dev-blinq/cucumber_client 1.0.1626-dev โ†’ 1.0.1628-dev

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.
@@ -244,6 +244,20 @@ export class RemoteBrowserService extends EventEmitter {
244
244
  const timestamp = new Date().toISOString();
245
245
  console.log(`[${timestamp}] [RemoteBrowserService] ${message}`, data ? JSON.stringify(data, null, 2) : "");
246
246
  }
247
+ isTransientPageDataError(error) {
248
+ const message = error instanceof Error ? error.message : typeof error === "string" ? error : undefined;
249
+ if (!message) {
250
+ return false;
251
+ }
252
+ const transientIndicators = [
253
+ "Execution context was destroyed",
254
+ "Execution context is not available",
255
+ "Cannot find context with specified id",
256
+ "Target closed",
257
+ "Navigation interrupted",
258
+ ];
259
+ return transientIndicators.some((indicator) => message.includes(indicator));
260
+ }
247
261
  /**
248
262
  * Gets the CDP Target ID for a page *directly* from the page.
249
263
  * This is the only reliable method during restarts.
@@ -277,7 +291,13 @@ export class RemoteBrowserService extends EventEmitter {
277
291
  for (const page of existingPages) {
278
292
  const stableTabId = uuidv4();
279
293
  const cdpTargetId = await this.getCdpTargetId(page);
280
- this.pages.set(stableTabId, { page, cdpTargetId });
294
+ this.pages.set(stableTabId, {
295
+ page,
296
+ cdpTargetId,
297
+ lastKnownTitle: undefined,
298
+ lastKnownUrl: page.url(),
299
+ lastKnownWsDebuggerUrl: cdpTargetId ? `${this.wsUrlBase}${cdpTargetId}` : undefined,
300
+ });
281
301
  this.log("โœ… Existing page added to map", { stableTabId, cdpTargetId, url: page.url() });
282
302
  this.attachPageLifecycleListeners(page, stableTabId);
283
303
  this.log("๐Ÿ” Attached lifecycle listeners to existing page", { stableTabId });
@@ -291,7 +311,13 @@ export class RemoteBrowserService extends EventEmitter {
291
311
  this.log("๐Ÿ†• New page event triggered", { stableTabId, url: page.url() });
292
312
  // We get the ID immediately, but it might be null if the page is too new
293
313
  const cdpTargetId = await this.getCdpTargetId(page);
294
- this.pages.set(stableTabId, { page, cdpTargetId });
314
+ this.pages.set(stableTabId, {
315
+ page,
316
+ cdpTargetId,
317
+ lastKnownTitle: undefined,
318
+ lastKnownUrl: page.url(),
319
+ lastKnownWsDebuggerUrl: cdpTargetId ? `${this.wsUrlBase}${cdpTargetId}` : undefined,
320
+ });
295
321
  if (cdpTargetId) {
296
322
  this.log("โœ… Page mapped to CDP ID", { stableTabId, cdpTargetId });
297
323
  }
@@ -336,6 +362,12 @@ export class RemoteBrowserService extends EventEmitter {
336
362
  const pagesData = [];
337
363
  const pagesToDelete = []; // To clean up closed pages
338
364
  for (const [stableTabId, pageInfo] of this.pages.entries()) {
365
+ const pageData = {
366
+ id: stableTabId,
367
+ title: pageInfo.lastKnownTitle ?? "",
368
+ url: pageInfo.lastKnownUrl ?? pageInfo.page.url(),
369
+ wsDebuggerUrl: pageInfo.lastKnownWsDebuggerUrl ?? "",
370
+ };
339
371
  try {
340
372
  if (pageInfo.page.isClosed()) {
341
373
  this.log("๐Ÿงน Found closed page during getState, marking for deletion", { stableTabId });
@@ -349,23 +381,35 @@ export class RemoteBrowserService extends EventEmitter {
349
381
  pageInfo.cdpTargetId = currentCdpId; // Update our internal reference
350
382
  }
351
383
  // Manually construct the WebSocket URL
352
- const wsDebuggerUrl = currentCdpId ? `${this.wsUrlBase}${currentCdpId}` : "";
384
+ const wsDebuggerUrl = currentCdpId ? `${this.wsUrlBase}${currentCdpId}` : pageInfo.lastKnownWsDebuggerUrl ?? "";
353
385
  if (!wsDebuggerUrl) {
354
386
  this.log("โš ๏ธ Could not get CDP ID, wsDebuggerUrl will be empty", { stableTabId });
355
387
  }
356
388
  const title = await pageInfo.page.title();
357
- pagesData.push({
358
- id: stableTabId,
359
- title,
360
- url: pageInfo.page.url(),
361
- wsDebuggerUrl: wsDebuggerUrl, // Use the constructed URL
362
- });
363
- this.log(`๐ŸŸฅPage data: ${JSON.stringify(pagesData, null, 2)}`);
389
+ const currentUrl = pageInfo.page.url();
390
+ pageData.title = title;
391
+ pageData.url = currentUrl;
392
+ pageData.wsDebuggerUrl = wsDebuggerUrl; // Use the constructed URL
393
+ pageInfo.lastKnownTitle = title;
394
+ pageInfo.lastKnownUrl = currentUrl;
395
+ pageInfo.lastKnownWsDebuggerUrl = wsDebuggerUrl;
396
+ this.log("๐ŸŸฅPage data", pageData);
364
397
  }
365
398
  catch (error) {
366
- this.log("โŒ Error getting page data", { stableTabId, error });
367
- pagesToDelete.push(stableTabId); // Mark for deletion
399
+ const message = error instanceof Error ? error.message : JSON.stringify(error);
400
+ if (this.isTransientPageDataError(error)) {
401
+ this.log("โณ Transient error getting page data, will retry", { stableTabId, message });
402
+ }
403
+ else {
404
+ this.log("โŒ Error getting page data", { stableTabId, message });
405
+ pagesToDelete.push(stableTabId); // Mark for deletion
406
+ continue;
407
+ }
408
+ }
409
+ if (!pageData.title) {
410
+ pageData.title = pageInfo.page.url() === "about:blank" ? "" : "Loading...";
368
411
  }
412
+ pagesData.push(pageData);
369
413
  }
370
414
  pagesToDelete.forEach((id) => this.pages.delete(id));
371
415
  if (this._selectedPageId && !this.pages.has(this._selectedPageId)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1626-dev",
3
+ "version": "1.0.1628-dev",
4
4
  "description": " ",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "@cucumber/tag-expressions": "^6.1.1",
40
40
  "@dev-blinq/cucumber-js": "1.0.208-dev",
41
41
  "@faker-js/faker": "^8.4.1",
42
- "automation_model": "1.0.893-dev",
42
+ "automation_model": "1.0.894-dev",
43
43
  "axios": "^1.7.4",
44
44
  "chokidar": "^3.6.0",
45
45
  "create-require": "^1.1.1",
@@ -68,6 +68,7 @@
68
68
  "mocha": "^10.2.0",
69
69
  "ncp": "^2.0.0",
70
70
  "readline-sync": "^1.4.10",
71
+ "ts-node": "^10.9.2",
71
72
  "tsup": "^8.5.0",
72
73
  "typescript": "^5.9.2"
73
74
  }