rokucommunity / rokucommunity/brighterscript
Build crashes on files a plugin adds to event.files after the prepare phase
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 208
- Forks
- 68
- Avg merge
- 8h 39m
- Merged PRs (30d)
- 39
Description
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:
file.editor?.undoAll();
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Program.build(), especially the cleanup loop that calls undoAll() on event.files after serialization. Reproduce the issue by adding a file through the documented afterPrepareProgram hook, then verify that the build completes without a TypeError. Done means late-added files no longer crash cleanup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100