@@ -21,7 +21,7 @@ import groovy.transform.ToString
2121import groovy.util.logging.Slf4j
2222import nextflow.Session
2323import nextflow.container.resolver.ContainerMeta
24- import nextflow.exception.AbortOperationException
24+ import nextflow.exception.AbortRunException
2525import nextflow.processor.TaskHandler
2626import nextflow.processor.TaskId
2727import nextflow.processor.TaskProcessor
@@ -156,7 +156,7 @@ class TowerObserver implements TraceObserverV2 {
156156 final ret = client. traceCreate(makeCreateReq(session), workspaceId)
157157 this . workflowId = ret. workflowId
158158 if ( ! workflowId )
159- throw new AbortOperationException (" Invalid Seqera Platform API response - Missing workflow Id" )
159+ throw new AbortRunException (" Invalid Seqera Platform API response - Missing workflow Id" )
160160 log. debug " Platform workflow id: $workflowId ; workflow url: ${ ret.watchUrl} "
161161 session. workflowMetadata. platform. workflowId = workflowId
162162 // note: `watchUrl` in the create response requires Platform 26.01 or later
@@ -530,46 +530,53 @@ class TowerObserver implements TraceObserverV2 {
530530
531531
532532 protected void sendTasks0 (dummy ) {
533- final tasks = new HashMap<TaskId , TraceRecord > (TASKS_PER_REQUEST )
534- boolean complete = false
535- long previous = System . currentTimeMillis()
536- final long period = requestInterval. millis
537- final long delay = period / 10 as long
538-
539- while ( ! complete ) {
540- final ProcessEvent ev = events. poll(delay, TimeUnit . MILLISECONDS )
541- // reconcile task events ie. send out only the last event
542- if ( ev ) {
543- log. trace " Tower event=$ev "
544- if ( ev. trace )
545- tasks[ev. trace. taskId] = ev. trace
546- if ( ev. completed )
547- complete = true
548- }
549-
550- // check if there's something to send
551- final now = System . currentTimeMillis()
552- final delta = now - previous
533+ try {
534+ final tasks = new HashMap<TaskId , TraceRecord > (TASKS_PER_REQUEST )
535+ boolean complete = false
536+ long previous = System . currentTimeMillis()
537+ final long period = requestInterval. millis
538+ final long delay = period / 10 as long
539+
540+ while ( ! complete ) {
541+ final ProcessEvent ev = events. poll(delay, TimeUnit . MILLISECONDS )
542+ // reconcile task events ie. send out only the last event
543+ if ( ev ) {
544+ log. trace " Tower event=$ev "
545+ if ( ev. trace )
546+ tasks[ev. trace. taskId] = ev. trace
547+ if ( ev. completed )
548+ complete = true
549+ }
553550
554- if ( ! tasks ) {
555- if ( delta > aliveInterval. millis ) {
556- final req = makeHeartbeatReq()
557- client. traceHeartbeat(req, workspaceId, workflowId)
558- previous = now
551+ // check if there's something to send
552+ final now = System . currentTimeMillis()
553+ final delta = now - previous
554+
555+ if ( ! tasks ) {
556+ if ( delta > aliveInterval. millis ) {
557+ final req = makeHeartbeatReq()
558+ client. traceHeartbeat(req, workspaceId, workflowId)
559+ previous = now
560+ }
561+ continue
559562 }
560- continue
561- }
562563
563- if ( delta > period || tasks. size() >= TASKS_PER_REQUEST || complete ) {
564- // send
565- final req = makeTasksReq(tasks. values())
566- client. traceProgress(req, workspaceId, workflowId)
564+ if ( delta > period || tasks. size() >= TASKS_PER_REQUEST || complete ) {
565+ // send
566+ final req = makeTasksReq(tasks. values())
567+ client. traceProgress(req, workspaceId, workflowId)
567568
568- // clean up for next iteration
569- previous = now
570- tasks. clear()
569+ // clean up for next iteration
570+ previous = now
571+ tasks. clear()
572+ }
571573 }
572574 }
575+ catch ( Exception e ) {
576+ this . sender = null
577+ log. error(" Aborting session due to Seqera Platform telemetry exception - $e. message " , e)
578+ session. abort(e)
579+ }
573580 }
574581
575582}
0 commit comments