wb-browser-runtime 0.6.0 → 0.6.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/bin/wb-browser-runtime.js +10 -4
- package/package.json +1 -1
|
@@ -946,12 +946,18 @@ async function runVerb(page, verb, index, ctx) {
|
|
|
946
946
|
);
|
|
947
947
|
}
|
|
948
948
|
await fsPromises.mkdir(path.dirname(full), { recursive: true });
|
|
949
|
-
//
|
|
950
|
-
//
|
|
951
|
-
//
|
|
949
|
+
// Atomic write via tmp + rename so a crash mid-capture can't leave a
|
|
950
|
+
// truncated PNG that's already been announced via slice.artifact_saved
|
|
951
|
+
// and uploaded to R2. We capture to a Buffer (with `type` derived from
|
|
952
|
+
// the requested extension) and write it ourselves — passing a `.tmp`
|
|
953
|
+
// path directly to Playwright fails because it infers format from the
|
|
954
|
+
// file extension and rejects unknown ones.
|
|
955
|
+
const ext = path.extname(full).toLowerCase();
|
|
956
|
+
const type = ext === ".jpg" || ext === ".jpeg" ? "jpeg" : "png";
|
|
952
957
|
const tmp = `${full}.${process.pid}.${randomUUID().slice(0, 8)}.tmp`;
|
|
953
958
|
try {
|
|
954
|
-
await page.screenshot({
|
|
959
|
+
const buf = await page.screenshot({ type, fullPage: !!a.full_page });
|
|
960
|
+
await fsPromises.writeFile(tmp, buf);
|
|
955
961
|
await fsPromises.rename(tmp, full);
|
|
956
962
|
} catch (e) {
|
|
957
963
|
try {
|
package/package.json
CHANGED