Problem with Undo and File

Writing an InDesign UXP plugin I want to perform a file-related action and wrap that in one undo step. Unfortunately, as soon as I create the file object, the undo recording stops. The function continues to run and works fine, but all steps in the layout after the creation of the file object get their own undo step, which is annoying for the user (and possibly impacting performance).

Simplified version of my code:

const indesign = require("indesign"),
    app =,
    uxpStorage = require('uxp').storage,
    fs = uxpStorage.localFileSystem;

app.doScript(placeImage.bind(this, imgSrcUrl, page), indesign.ScriptLanguage.UXPSCRIPT, 
				 undefined, indesign.UndoModes.ENTIRE_SCRIPT, "place an image");

async function placeImage(imgSrcUrl, page) {
    const frame = page.rectangles.add( ... );   // Rectangle constructor
    frame.applyObjectStyle(obStyle, true);     // obStyle: my preferred ObjectStyle

    const resp = await fetch(imgSrcUrl);
    const buffer = await resp.arrayBuffer();

    const tmpFile = await tmpFolder.createEntry(fileName, {overwrite: true});
        // from now on, all layout-related actions get their own undo step
    const bytesWritten = await tmpFile.write(buffer, {format: uxpStorage.formats.binary});;

Using the fs module to write the file, this does not occur, InDesign keeps recording the undo action. But for I need a File object.

For me, this looks like a bug. Any ideas or workarounds?