Skip to content

fix callback err not return #6856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NameHaibinZhang
Copy link
Member

for _, c := range p.callbacks {
	// TODO make the callbacks parallel. ( #3034 )
	if e := c(ctx); e != nil {
		err = errors.Join(err, e)
	}
	if err := ctx.Err(); err != nil {
		rm.Resource = nil
		clear(rm.ScopeMetrics) // Erase elements to let GC collect objects.
		rm.ScopeMetrics = rm.ScopeMetrics[:0]
		return err
	}
}
for e := p.multiCallbacks.Front(); e != nil; e = e.Next() {
	// TODO make the callbacks parallel. ( #3034 )
	f := e.Value.(multiCallback)
	if e := f(ctx); e != nil {
		err = errors.Join(err, e)
	}
	if err := ctx.Err(); err != nil {
		// This means the context expired before we finished running callbacks.
		rm.Resource = nil
		clear(rm.ScopeMetrics) // Erase elements to let GC collect objects.
		rm.ScopeMetrics = rm.ScopeMetrics[:0]
		return err
	}
}

if ctx.Err() is not nil, the c(ctx) err is not return

Copy link

linux-foundation-easycla bot commented May 30, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: NameHaibinZhang / name: Zhanghaibin (9e8fd14)

@pellared
Copy link
Member

pellared commented May 30, 2025

Thank you for the PR.

Can you add a changelog entry and add a unit tests to cover these cases?

@NameHaibinZhang
Copy link
Member Author

Thank you for the PR.

Can you add a changelog entry and add a unit tests to cover these cases?

ok,i will add test

@pellared pellared added this to the Subsequent v1.37.0 milestone Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants