Skip to content

[Bug] ARTRestChannel.m history method uses art_dispatch_sync instead of art_dispatch_async #2175

@coderabbitai

Description

@coderabbitai

Description

In Source/ARTRestChannel.m around lines 241-244, the history: method uses art_dispatch_sync(_queue, ...) which creates a deadlock risk and blocks the calling thread unnecessarily.

Problem

  1. Deadlock Risk: If history: is called from code already executing on _queue, it will deadlock
  2. Blocking: Using sync dispatch blocks the caller's thread when the work is being dispatched asynchronously anyway
  3. Inconsistency: Similar paginated methods in the codebase use art_dispatch_async:
    • ARTRestPresence.m (lines 171, 237)
    • ARTRest.m (lines 771, 845)

Expected Behavior

The method should use art_dispatch_async(_queue, ^{ ... }) to match the pattern used in similar paginated methods.

Code Location

// Current (incorrect):
art_dispatch_sync(_queue, ^{
    [ARTPaginatedResult executePaginated:self->_rest withRequest:request andResponseProcessor:responseProcessor wrapperSDKAgents:wrapperSDKAgents logger:self.logger callback:callback];
});

// Should be:
art_dispatch_async(_queue, ^{
    [ARTPaginatedResult executePaginated:self->_rest withRequest:request andResponseProcessor:responseProcessor wrapperSDKAgents:wrapperSDKAgents logger:self.logger callback:callback];
});

Context

This issue was identified during code review of PR #2164 and confirmed to be legacy code that should be fixed.

Related:

┆Issue is synchronized with this Jira Bug by Unito

Metadata

Metadata

Assignees

Labels

bugSomething isn't working. It's clear that this does need to be fixed.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions