event target registration failures must be returned (#16700)

This commit is contained in:
Harshavardhana 2023-02-23 08:29:14 -08:00 committed by GitHub
parent 2bbf380262
commit b21d3f9b82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,10 +41,11 @@ func (l *lazyInit) doSlow(f func() error) error {
l.m.Lock()
defer l.m.Unlock()
if atomic.LoadUint32(&l.done) == 0 {
if f() == nil {
// Mark as done only when f() is successful
atomic.StoreUint32(&l.done, 1)
if err := f(); err != nil {
return err
}
// Mark as done only when f() is successful
atomic.StoreUint32(&l.done, 1)
}
return nil
}