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.
@@ -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
- // Write to a unique .tmp first, then atomically rename, so a crash
950
- // mid-capture can't leave a truncated PNG that's already been announced
951
- // via slice.artifact_saved and uploaded to R2.
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({ path: tmp, fullPage: !!a.full_page });
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wb-browser-runtime",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Browser sidecar runtime for wb — Browserbase + Playwright over the wb-sidecar/1 line-framed JSON protocol.",
5
5
  "bin": {
6
6
  "wb-browser-runtime": "bin/wb-browser-runtime.js"