Skip to content

Race condition in FileCacheRetriever::cleanExpiredCache causes unlink warning #11

@angelopinto-conexa

Description

@angelopinto-conexa

Problem

We are seeing intermittent production errors in the Efí PHP SDK during webhook processing.

The error happens inside the SDK cache cleanup flow:

ErrorException: Warning: unlink(/tmp/efi_cache/16a988f645d35901f1950abe61c611123173dcc4465ae70ed81e0cf46333f003): No such file or directory

Stack trace points to:

vendor/efipay/sdk-php-apis-efi/src/Efi/FileCacheRetriever.php
Efi\FileCacheRetriever::cleanExpiredCache
context line: unlink($file);

Our application code only calls:

$api = new EfiPay($options);
$chargeNotification = $api->getNotification($params, []);

Context

This happens during webhook notification handling.

The error appears to be related to the SDK file cache cleanup in /tmp/efi_cache.

Since webhook requests can happen concurrently, it seems possible that one process removes a cache file while another process is also trying to clean it.

When this happens, PHP raises a warning because the file no longer exists. In our framework, this warning becomes an unhandled ErrorException.

Expected behavior

The SDK cache cleanup should not fail the request if a cache file was already removed or is no longer available.

Environment

  • SDK package: efipay/sdk-php-apis-efi
  • Method used: EfiPay::getNotification
  • Cache directory involved: /tmp/efi_cache
  • Runtime: PHP application handling webhook requests

Question

Could you please check whether FileCacheRetriever::cleanExpiredCache() should tolerate cache files that no longer exist during cleanup?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions