Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-31314

Running asynchronous code inside a @NonCPS method should fail cleanly

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      User-visible bit: throws an error

       

      Currently if you run a step with asynchronous execution (which is to say, almost all of them, since AbstractSynchronousNonBlockingStepExecution counts) inside a method marked @NonCPS, or otherwise not transformed (for example because of JENKINS-26481), you get bizarre results: the return value of the step becomes the return value of the method, regardless of what was supposed to happen in the rest of the method. This is because CpsCallableInvocation is thrown from DSL.invokeMethod and interrupts the method's execution.

      This is very confusing behavior. It would be better for CpsCallableInvocation.<init> to somehow detect that it is inside an untransformed method and throw a comprehensible error.

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            Not sure. Linked to a sketch of doing the detection for the originally suggested case. Definitely there are others, and those might be harder to handle—I am not sure. Maybe you can figure something out from these hints.

            Show
            jglick Jesse Glick added a comment - Not sure. Linked to a sketch of doing the detection for the originally suggested case. Definitely there are others, and those might be harder to handle—I am not sure. Maybe you can figure something out from these hints.
            Hide
            jglick Jesse Glick added a comment -

            Seems to be catching the cases I would want it to catch. For now it is catching too much, and it will be some work to prune the warnings back to legitimate cases.

            Show
            jglick Jesse Glick added a comment - Seems to be catching the cases I would want it to catch. For now it is catching too much, and it will be some work to prune the warnings back to legitimate cases.
            Hide
            abayer Andrew Bayer added a comment -

            I’ll take a look tomorrow.

            Show
            abayer Andrew Bayer added a comment - I’ll take a look tomorrow.
            Hide
            yngvark Yngvar Kristiansen added a comment -

            Any progress on this?

            Show
            yngvark Yngvar Kristiansen added a comment - Any progress on this?
            Hide
            jglick Jesse Glick added a comment -

            No, I had a prototype but stopped work on this.

            Show
            jglick Jesse Glick added a comment - No, I had a prototype but stopped work on this.

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                jglick Jesse Glick
              • Votes:
                16 Vote for this issue
                Watchers:
                23 Start watching this issue

                Dates

                • Created:
                  Updated: