This is very confusing as seen in #12974 or #12906. My suggestion would be "legacy."
});
    handler.on(
      "SaveDocument",
      function ({ numPages, annotationStorage, filename }) {
        pdfManager.requestLoadedStream();
        const promises = [
          pdfManager.onLoadedStream(),
          pdfManager.ensureCatalog("acroForm"),
          pdfManager.ensureDoc("xref"),
          pdfManager.ensureDoc("startXRef"),
        ];
        for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
          promises.push(
            pdfManager.getPage(pageIndex).then(function (page) {
              const task = new WorkerTask(`Save: page ${pageIndex}`);
              startWorkerTask(task);
              return page
                .save(handler, task, annotationStorage)
                .finally(function () {
                  finishWorkerTask(task);
                });
            })
          );
        }
        return Promise.all(promises).then(function ([
          stream,
          acroForm,
          xref,
          startXRef,
          ...refs