diff --git a/object.go b/object.go index 6bce60575..9d558cc6e 100644 --- a/object.go +++ b/object.go @@ -622,6 +622,7 @@ func (obs *obs) Get(name string, opts ...GetObjectOpt) (ObjectResult, error) { result.digest = sha256.New() processChunk := func(m *Msg) { + var err error if ctx != nil { select { case <-ctx.Done(): diff --git a/test/object_test.go b/test/object_test.go index 14e0819b2..550015cd8 100644 --- a/test/object_test.go +++ b/test/object_test.go @@ -97,6 +97,12 @@ func TestObjectBasics(t *testing.T) { expectOk(t, result.Error()) defer result.Close() + // Now get the object back with a context option. + result, err = obs.Get("BLOB", nats.Context(context.Background())) + expectOk(t, err) + expectOk(t, result.Error()) + defer result.Close() + // Check info. info, err = result.Info() expectOk(t, err)