fix(screenshots): keep default navigation wait

Waiting for `load` risks exhausting the 30s request budget on sites with
slow or hanging load-blocking subresources, which fails the capture
outright instead of producing a slightly early one. The existing sleep
already covers most of the settling this was meant to buy.
This commit is contained in:
Chirag Aggarwal committed 2026-07-27 13:33:33 +05:30
1 parent caed7aad24
commit 27e79e5d0c
2 files changed
+6 -12

No files matched your search

-7
View File
@@ -20,12 +20,6 @@ class Client
*/
public const SCALE = 1.5;
/**
* Wait for subresources such as webfonts and images, not just the DOM,
* otherwise pages are captured mid-render.
*/
public const WAIT_UNTIL = 'load';
private Factory $factory;
/**
@@ -55,7 +49,6 @@ class Client
'height' => self::VIEWPORT_HEIGHT,
],
'deviceScaleFactor' => self::SCALE,
'waitUntil' => self::WAIT_UNTIL,
]));
$status = $response->getStatusCode();
+6 -5
View File
@@ -60,7 +60,6 @@ final class ClientTest extends TestCase
'sleep' => 500,
'viewport' => ['width' => 1280, 'height' => 720],
'deviceScaleFactor' => 1.5,
'waitUntil' => 'load',
], \json_decode((string)$this->request->getBody(), true));
}
@@ -80,16 +79,18 @@ final class ClientTest extends TestCase
$this->assertSame(720, $body['viewport']['height']);
}
public function testCreateWaitsForSubresources(): void
public function testCreateDoesNotBlockOnSubresources(): void
{
$response = (new Response(200, body: new Stream('png-bytes')))
->withHeader('Content-Type', 'image/png');
$this->client($response)->create('http://appwrite/', 'light');
// The browser service defaults to `domcontentloaded`, which fires before
// webfonts and images have settled.
$this->assertSame('load', \json_decode((string)$this->request->getBody(), true)['waitUntil']);
// The browser service navigates with `domcontentloaded` unless told
// otherwise. Waiting for `load` risks exhausting the request timeout on
// sites with slow or hanging subresources, which yields no screenshot at
// all rather than an early one.
$this->assertArrayNotHasKey('waitUntil', \json_decode((string)$this->request->getBody(), true));
}
public function testCreateError(): void