nextflow icon indicating copy to clipboard operation
nextflow copied to clipboard

Exit error message not printed to screen when used between process input brackets.

Open mahesh-panchal opened this issue 1 year ago • 3 comments

Bug report

When using exit <exit code>, <message>, the message is not printed to the screen when it is between process input brackets.

Expected behavior and actual behavior

The expected behaviour is that exit messages are always printed to screen ( and log ). The actual behaviour is that this happens only when the exit is outside of a process input brackets.

Steps to reproduce the problem

Prints exit message to screen (outside.nf):

workflow {
    log.info("Starting workflow")
    Channel.empty()
        .ifEmpty { exit 1, "ERROR: error message\n" }
}

Does not print exit message to screen (inside.nf):

workflow {
    log.info("Starting workflow")
    FOO(
        Channel.empty()
            .ifEmpty { exit 1, "ERROR: error message\n" }
    )
}

process FOO {
    input:
    val message

    exec:
    println message
}

Program output

outside.nf:

% nextflow run outside.nf 
N E X T F L O W  ~  version 22.04.4
Launching `outside.nf` [backstabbing_varahamihira] DSL2 - revision: 798478e9c7
Starting workflow
ERROR: error message


inside.nf:

% nextflow run inside.nf 
N E X T F L O W  ~  version 22.04.4
Launching `inside.nf` [nostalgic_minsky] DSL2 - revision: 020266ff03
Starting workflow

Environment

  • Nextflow version: 22.04.4
  • Java version: openjdk 11.0.9.1 2020-11-04 LTS
  • Operating system: macOS
  • Bash version: zsh 5.8 (x86_64-apple-darwin21.0)

Additional context

(Add any other context about the problem here)

mahesh-panchal avatar Jul 20 '22 08:07 mahesh-panchal

where I can found information about exit <exit code>, <message> statement? couldn't find into code

jorgeaguileraseqera avatar Jul 22 '22 18:07 jorgeaguileraseqera

I didn't realise it was Nextflow specific. I guess it's this chunk: https://github.com/nextflow-io/nextflow/blob/b7bf9fe51ba099e44f18d2fbccd4360e48f4977a/modules/nextflow/src/main/groovy/nextflow/Nextflow.groovy#L233-L246

mahesh-panchal avatar Jul 23 '22 18:07 mahesh-panchal

I was playing a little with bot scripts and found that in both cases the message is dumped to log (but not to screen as you detected)

when the exit is called outside a process the last lines of the logs are (similar) to:

jul-25 09:12:18.514 [main] DEBUG nextflow.script.ScriptRunner - > Await termination 
jul-25 09:12:18.514 [main] DEBUG nextflow.Session - Session await
jul-25 09:12:18.514 [main] DEBUG nextflow.Session - Session await > all process finished
jul-25 09:12:18.514 [main] DEBUG nextflow.Session - Session await > all barriers passed
jul-25 09:12:18.516 [Actor Thread 4] ERROR nextflow.Nextflow - ERROR: error message

and when it's into the process the log look as:

jul-25 09:13:45.254 [main] DEBUG nextflow.Session - Ignite dataflow network (2)
jul-25 09:13:45.255 [main] DEBUG nextflow.processor.TaskProcessor - Starting process > FOO
jul-25 09:13:45.255 [main] DEBUG nextflow.script.ScriptRunner - > Await termination 
jul-25 09:13:45.255 [main] DEBUG nextflow.Session - Session await
jul-25 09:13:45.256 [Actor Thread 4] ERROR nextflow.Nextflow - ERROR: error message

So the code is executed but I think the LogAppender associated with the console doesn't have time to output the message

jorgeaguileraseqera avatar Jul 25 '22 13:07 jorgeaguileraseqera

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 31 '22 21:12 stale[bot]

Jorge's commit should have closed this issue, so I'm closing it now.

mribeirodantas avatar Jan 01 '23 16:01 mribeirodantas