question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Timeout + hooks (on-timedout, before-comment)

See original GitHub issue
Recently, 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:open
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
ortacommented, Jul 13, 2020

This could be a general Dangerfile API which plugins could use:

import {danger} from "danger"

danger.hooks.beforeComments((violations: Voilations[])=> {

})

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.

0reactions
ortacommented, Jul 14, 2020

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 array

danger.hooks.addViolationsFinalizedProcessor happens as the process is closing, with all of them

Truncating 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

useTimeout, a setTimeout hook for React - Josh W Comeau
If our parent component re-renders 10 times, we'll schedule 10 timeouts. Our callback function is stale; it won't have access to current values ......
Read more >
Using setTimeout in React components (including hooks)
The setTimeout function accepts two arguments: the first is the callback function that we want to execute, and the second specifies the timeout...
Read more >
useTimeout() react hook - usehooks-ts
useTimeout (). Very similar to the useInterval hook, this React hook implements the native setTimeout function keeping the same interface.
Read more >
React hooks - right way to clear timeouts and intervals
Defined return () => { /*code/* } function inside useEffect runs every time useEffect runs (except first render on component mount) and on...
Read more >
setTimeout in React Components Using Hooks - Upmostly
!') }, 1000); return () => clearTimeout(timer); }, []);. What is setTimeout? The setTimeout method calls a function or runs some code after...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found