Skip to content

Commit

Permalink
distinguish internal timeouts vs external timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Oct 14, 2021
1 parent 273499b commit d3e31d5
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -52,19 +52,28 @@ export class ScreenshotObservableHandler {
label: 'render complete',
};

private readonly timeouts: {
openUrl: number;
waitForElements: number;
};

constructor(
private readonly driver: HeadlessChromiumDriver,
private readonly captureConfig: CaptureConfig,
private captureConfig: CaptureConfig,
opts: ScreenshotObservableOpts
) {
this.conditionalHeaders = opts.conditionalHeaders;
this.layout = opts.layout;
this.logger = opts.logger;
this.timeouts = {
openUrl: durationToNumber(captureConfig.timeouts.openUrl),
waitForElements: durationToNumber(captureConfig.timeouts.waitForElements),
};
}

/*
* This wraps a chain of observable operators in a timeout, and decorates a
* timeout error to specify which phase of page capture has timed out.
* This "external timeout" wraps a chain of observable operators in a
* timeout, and decorates a TimeoutError to specify which phase of page capture has timed out.
*/
private waitUntil<O, P>(phase: PhaseInstance, chain: Rx.OperatorFunction<O, P>) {
const { timeoutValue, label, configValue } = phase;
@@ -101,7 +110,7 @@ export class ScreenshotObservableHandler {
return initial.pipe(
mergeMap(() =>
openUrl(
durationToNumber(this.captureConfig.timeouts.openUrl),
this.timeouts.openUrl, // internal timeout
this.driver,
index,
urlOrUrlLocatorTuple,
@@ -119,7 +128,7 @@ export class ScreenshotObservableHandler {
return withPageOpen.pipe(
mergeMap(() =>
getNumberOfItems(
durationToNumber(this.captureConfig.timeouts.waitForElements),
this.timeouts.waitForElements, // internal timeout
driver,
this.layout,
this.logger
@@ -131,7 +140,7 @@ export class ScreenshotObservableHandler {
await Promise.all([
driver.setViewport(viewport, this.logger),
waitForVisualizations(
durationToNumber(this.captureConfig.timeouts.renderComplete),
this.timeouts.waitForElements, // internal timeout
driver,
itemsCount,
this.layout,

0 comments on commit d3e31d5

Please sign in to comment.