Skip to content

Fatal issue when handler  #59

@jeromediaz

Description

@jeromediaz

On the following piece of code

[ping startPingingWithBlock:^(GBPingSummary *summary) {
if (!ping) {
return;
}
resolve(@(@(summary.rtt * 1000).intValue));
[ping stop];
ping = nil;
} fail:^(NSError *_Nonnull error) {
if (!ping) {
return;
}
reject(@(error.code).stringValue,error.domain,error);
[ping stop];
ping = nil;
}];

there is a flaw: there is no guarantee the resolve (or reject) call will be finished before the second ping arrive, which would result on a fatal issue as those handlers can only be called once

those handlers should either :

  • be call asynchronously,
  • be called after [ping stop]

for those encountering the issue before it is corrected, you can handle the ping answer in js using a
setTimeout(() => { // do your stuff} , 0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions