[Feature] Timeout + hooks (on-timedout, before-comment)
See original GitHub issueRecently, we did a big folder move in preparation for having monorepo. -- Expand for Context
A consequence of this was that every file in the repo was tagged as having been modified. – This then caused danger-plugin-eslint to execute on every file – but due to a configuration error, this caused DangerJS to hang until terminated by Github Actions (20mins later) as each file individually did a lot of processing before throwing errors.
I think it would be very useful if I could configure danger with a hardcoded timeout so that it never takes long enough to fail to report.
Related to this, I had put code in a schedule
block to truncate DangerJS output if it was too long as this was causing Github to fail to post the comment. – Unfortunately, in the situation described above, this code actually executed before previous schedule
blocks are complete meaning that it logged debug logs and implies that schedule
-block execution is happening in parallel. – I thought that schedule blocks are serially executed.
This misunderstanding means that my truncation code probably works only due to a timing fluke.
If I add a timeout feature, it would be useful to have a beforeCommentsPosted
hook and an onTimedOut
hook. The onTimedOut
hook would be useful to add an additional message, while the beforeCommentsPosted
hook would be useful to implement the truncation
feature.
Any thoughts @orta or somebody else?
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
This could be a general Dangerfile API which plugins could use:
But a timeout in user-code evaluation isn’t really the responsibility of Danger, though 20m is pretty wild. I’m not opposed to the idea of a timeout of 10m by default and then just posting something back to the PR.
danger.hooks.addViolationsProcessor
happens every time anyone creates a violition, letting you amend, add an extra or remove it because it comes in as a singular and leaves as an arraydanger.hooks.addViolationsFinalizedProcessor
happens as the process is closing, with all of themTruncating should be in core https://github.com/danger/danger-js/issues/919 - but your sample is a good case for the split, you want a timeout which is reset when a violation has been submitted so you use
danger.hooks.addViolationsProcessor
.