Skip to content
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

ErrNoRows returned when context cancelled during Query.Bind #1443

Open
luiscleto opened this issue Mar 10, 2025 · 0 comments
Open

ErrNoRows returned when context cancelled during Query.Bind #1443

luiscleto opened this issue Mar 10, 2025 · 0 comments

Comments

@luiscleto
Copy link

On version v4.13.0, we noticed that when dealing with context timeouts, we'd sometimes get an unexpected sql.ErrNoRows rather than the expected context error which broke some of our error handling logic.

I believe this happens when a context times out while trying to Find a specific row (bkind == kindStruct) right before rows.Next() gets called.

In this case, rows.Next() will return false and bind will return sql.ErrNoRows. This results in Query.Bind returning the error immediately without doing a rows.Err() check.
Could be addressed by either checking for rows.Err() outside the for rows.Next() or within the error handling when the call to bind returns an error.

Reproduced with a context timeout and a breakpoint before entering the for rows.Next() loop, don't have unit test that could be easily used to reproduce this specific error scenario otherwise

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

No branches or pull requests

1 participant