diff --git a/network/dag/notifier.go b/network/dag/notifier.go index e01c87adc8..675b3882bf 100644 --- a/network/dag/notifier.go +++ b/network/dag/notifier.go @@ -23,6 +23,8 @@ import ( "encoding/json" "errors" "fmt" + "github.com/nuts-foundation/nuts-node/jsonld" + "strings" "time" "github.com/avast/retry-go/v4" @@ -246,6 +248,11 @@ func (p *notifier) Run() error { event := Event{} _ = json.Unmarshal(v, &event) + // Do not retry events that previously failed on an unknown context. See https://github.com/nuts-foundation/nuts-node/issues/2569 + if strings.HasSuffix(event.Error, jsonld.ContextURLNotAllowedErr.Error()) { + return nil + } + if err := p.notifyNow(event); err != nil { if event.Retries < maxRetries { failedAtStartup = append(failedAtStartup, event) diff --git a/network/dag/notifier_test.go b/network/dag/notifier_test.go index 075b08b503..fe20363dca 100644 --- a/network/dag/notifier_test.go +++ b/network/dag/notifier_test.go @@ -25,6 +25,7 @@ import ( "errors" "github.com/nuts-foundation/go-stoabs" "github.com/nuts-foundation/nuts-node/crypto/hash" + "github.com/nuts-foundation/nuts-node/jsonld" "github.com/nuts-foundation/nuts-node/storage" "github.com/nuts-foundation/nuts-node/test" "github.com/nuts-foundation/nuts-node/test/io" @@ -415,6 +416,25 @@ func TestNotifier_Run(t *testing.T) { return index != -1, nil }, time.Second, "timeout while waiting for go routine to start") }) + + t.Run("OK - does not retry unknown context errors", func(t *testing.T) { + ctx := context.Background() + filePath := io.TestDirectory(t) + kvStore := storage.CreateTestBBoltStore(t, path.Join(filePath, "test.db")) + counter := callbackCounter{} + s := NewNotifier(t.Name(), counter.callbackFinished, WithPersistency(kvStore), WithRetryDelay(time.Millisecond)).(*notifier) + defer s.Close() + + event := Event{Error: "some error: " + jsonld.ContextURLNotAllowedErr.Error()} + _ = kvStore.WriteShelf(ctx, s.shelfName(), func(writer stoabs.Writer) error { + bytes, _ := json.Marshal(event) + return writer.Put(stoabs.BytesKey(event.Hash.Slice()), bytes) + }) + + err := s.Run() + require.NoError(t, err) + assert.Equal(t, int64(0), counter.N.Load()) + }) } func TestNotifier_VariousFlows(t *testing.T) {