Skip to content

Commit e362fd3

Browse files
committed
no cleanup happens between tests, so restore old global worker overwriting logic
1 parent f955187 commit e362fd3

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

worker.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ func newWorker(o workerOpt) (*worker, error) {
7979
// Check if a worker with the same fileName and moduleID already exists
8080
if existingWorkers, ok := workers[absFileName]; ok {
8181
for _, existingWorker := range existingWorkers {
82-
if existingWorker.moduleID == o.moduleID {
83-
if o.moduleID == 0 {
84-
return nil, fmt.Errorf("cannot add a multiple global workers with the same filename: %s", absFileName)
85-
}
82+
if existingWorker.moduleID == o.moduleID && o.moduleID != 0 {
8683
return existingWorker, nil
8784
}
8885
}
@@ -105,6 +102,14 @@ func newWorker(o workerOpt) (*worker, error) {
105102
// Check if we already have workers for this filename
106103
if _, ok := workers[absFileName]; !ok {
107104
workers[absFileName] = make([]*worker, 0)
105+
} else {
106+
// check if a global worker already exists and overwrite it instead of appending
107+
for i, existingWorker := range workers[absFileName] {
108+
if existingWorker.moduleID == 0 && o.moduleID == 0 {
109+
workers[absFileName][i] = w
110+
return w, nil
111+
}
112+
}
108113
}
109114
workers[absFileName] = append(workers[absFileName], w)
110115

0 commit comments

Comments
 (0)