Program.build() ends by undoing edits on every file it built:
for (const file of event.files) {
file.editor.undoAll();
}
Editors are assigned during prepare(), so any file a plugin pushes onto event.files after that point has no editor, and the build throws TypeError: Cannot read properties of undefined (reading 'undoAll').
This is reachable from a supported hook. afterPrepareProgram receives event.files and is documented as mutable, but a file added there misses editor assignment and crashes the build it was added to.
Where I hit it: rooibos generates its code-coverage component from data collected during prepareFile, so it can't be registered any earlier than afterPrepareProgram. Working around it by assigning an editor ourselves:
const file = program.setFile(entry, contents);
file.editor ??= new Editor();
That works, but it depends on a build-internal detail that plugins shouldn't need to know about.
Suggested fix — either guard the cleanup loop:
or assign an editor in the same loop that serializes, so late additions are covered. The guard alone is enough to stop the crash.
Seen on 1.0.0-alpha.53; the cleanup loop is unguarded on master as well.
Program.build()ends by undoing edits on every file it built:Editors are assigned during
prepare(), so any file a plugin pushes ontoevent.filesafter that point has noeditor, and the build throwsTypeError: Cannot read properties of undefined (reading 'undoAll').This is reachable from a supported hook.
afterPrepareProgramreceivesevent.filesand is documented as mutable, but a file added there misses editor assignment and crashes the build it was added to.Where I hit it: rooibos generates its code-coverage component from data collected during
prepareFile, so it can't be registered any earlier thanafterPrepareProgram. Working around it by assigning an editor ourselves:That works, but it depends on a build-internal detail that plugins shouldn't need to know about.
Suggested fix — either guard the cleanup loop:
or assign an editor in the same loop that serializes, so late additions are covered. The guard alone is enough to stop the crash.
Seen on
1.0.0-alpha.53; the cleanup loop is unguarded onmasteras well.