StackOverflowError when chaining modules for nf-test

Thanks, the problem was with the when block. Accessing VIZGENPOSTPROCESSING_PREPARESEGMENTATION.out.segmentation_files[0] seems to throw this error, although I am not sure exactly why. If I use channel operators to retrieve the output, as well as construct the whole segmentation input channel it works. Here’s my solution:

        when {
            process {
                """
                VIZGENPOSTPROCESSING_PREPARESEGMENTATION.out.segmentation_files
                    .flatten()
                    .last()
                    .set { segmentation_params_ch }

                Channel.of([
                    [ id:'test' ],
                    file("tmpdir", type: 'dir'),
                ])
                .combine(segmentation_params_ch) // segmentation params JSON file
                .combine(Channel.of(0)) // tile_index
                .set { seg_input_ch }

                input[0] = seg_input_ch
                input[1] = file('https://raw.githubusercontent.com/Vizgen/vpt-plugin-cellpose2/refs/heads/develop/example_analysis_algorithm/cellpose2_nuclei.json', checkIfExists: true)
                input[2] = []
                """
            }
        }