diff --git a/remote/cdp/StreamRegistry.jsm b/remote/cdp/StreamRegistry.jsm index f35ccacdffc4..8780c01c7f06 100644 --- a/remote/cdp/StreamRegistry.jsm +++ b/remote/cdp/StreamRegistry.jsm @@ -47,14 +47,16 @@ class StreamRegistry { async _discard(stream) { if (stream instanceof OS.File) { - const fileInfo = await stream.stat(); - stream.close(); + let fileInfo; // Also remove the temporary file try { + fileInfo = await stream.stat(); + + stream.close(); await OS.File.remove(fileInfo.path, { ignoreAbsent: true }); } catch (e) { - console.error(`Failed to remove ${fileInfo.path}: ${e.message}`); + console.error(`Failed to remove ${fileInfo?.path}: ${e.message}`); } } }