Reading file after applying template returns older version

Assuming the templates plugin is enabled, in the following code the first line inserts a template to the active file (and shows up immediately in the editor), but the second line prints the contents before applying the template.

await (this.app as any).internalPlugins?.plugins["templates"]?.instance.insertTemplate(template_file);
console.log(await this.app.vault.read(this.app.workspace.activeEditor?.file!));

Expected behaviour is that the printed content matches what is displayed in the editor. This also happens if I do this.app.vault.cachedRead.

If instead I add a timeout it works:

await (this.app as any).internalPlugins?.plugins["templates"]?.instance.insertTemplate(template_file);
await (new Promise(resolve => setTimeout(resolve, 5000)));
console.log(await this.app.vault.read(this.app.workspace.activeEditor?.file!));

How can I get the read method to get the updated content immediately after the template is applied?