Skip to content

Comments

fix: errors doesn't support concurrent#1370

Merged
hwbrzzl merged 3 commits intov1.17.xfrom
bowen/fix-concurrent-error
Feb 7, 2026
Merged

fix: errors doesn't support concurrent#1370
hwbrzzl merged 3 commits intov1.17.xfrom
bowen/fix-concurrent-error

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Feb 4, 2026

Greptile Overview

Greptile Summary

Fixed concurrency issues in the errors package by making error objects immutable - Args() and SetModule() now return new instances instead of mutating state.

  • Changed Args() and SetModule() methods to create new errorString instances with copied fields
  • Added Is() method for proper error comparison based on text content
  • Added comprehensive concurrent test suite verifying thread-safety with 100 goroutines
  • Updated queue/worker.go to call .Error() on immutable error objects
  • Fixed test expectations in queue tests to match new immutable behavior

Confidence Score: 5/5

  • Safe to merge - correctly fixes concurrency issues by making error objects immutable
  • The PR properly addresses the concurrency issue by changing from mutable to immutable error objects, includes comprehensive concurrent tests, and updates all call sites appropriately
  • No files require special attention

Important Files Changed

Filename Overview
errors/errors.go Changed Args() and SetModule() to return new instances instead of mutating state, added Is() method for error comparison
errors/errors_test.go Added comprehensive test coverage for concurrent error usage, verifying immutability and thread-safety

Sequence Diagram

sequenceDiagram
    participant Client
    participant ErrorBase as Base Error
    participant ErrorCopy1 as Error Copy 1
    participant ErrorCopy2 as Error Copy 2
    
    Note over Client,ErrorCopy2: Before (Mutable - Race Condition)
    Client->>ErrorBase: New("error: %s")
    Client->>ErrorBase: Args("value1") [mutates]
    Client->>ErrorBase: Args("value2") [mutates]
    Note over ErrorBase: Race condition!<br/>State corrupted
    
    Note over Client,ErrorCopy2: After (Immutable - Thread Safe)
    Client->>ErrorBase: New("error: %s")
    Client->>ErrorBase: Args("value1")
    ErrorBase->>ErrorCopy1: return new instance
    Client->>ErrorBase: Args("value2")
    ErrorBase->>ErrorCopy2: return new instance
    Note over ErrorBase,ErrorCopy2: Each goroutine has<br/>its own copy
Loading

@hwbrzzl hwbrzzl requested a review from a team as a code owner February 4, 2026 13:37
@hwbrzzl hwbrzzl changed the base branch from master to v1.17.x February 4, 2026 13:37
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.66%. Comparing base (2649a5e) to head (72a254a).
⚠️ Report is 3 commits behind head on v1.17.x.

Additional details and impacted files
@@             Coverage Diff             @@
##           v1.17.x    #1370      +/-   ##
===========================================
- Coverage    68.66%   68.66%   -0.01%     
===========================================
  Files          281      281              
  Lines        17698    17747      +49     
===========================================
+ Hits         12153    12186      +33     
- Misses        5043     5058      +15     
- Partials       502      503       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@almas-x almas-x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hwbrzzl hwbrzzl merged commit e53059d into v1.17.x Feb 7, 2026
12 of 13 checks passed
@hwbrzzl hwbrzzl deleted the bowen/fix-concurrent-error branch February 7, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants