Skip to content

Commit

Permalink
Merge pull request #5 from phpcfdi/version-3.0.2
Browse files Browse the repository at this point in the history
Mejorar `bin/sat-pys-scraper` con `MAX_TRIES`
  • Loading branch information
eclipxe13 authored Oct 17, 2024
2 parents c36792d + cc9fc8c commit 6631d87
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ jobs:
run: composer upgrade --no-interaction --no-progress --prefer-dist --no-dev
- name: System test with PHP ${{ matrix.php-version }}
run: php bin/sat-pys-scraper --json build/result.json --xml build/result.xml --sort key
env:
MAX_TRIES: 5
13 changes: 12 additions & 1 deletion bin/sat-pys-scraper
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,15 @@ use PhpCfdi\SatPysScraper\App\SatPysScraper;

require __DIR__ . '/../vendor/autoload.php';

exit(SatPysScraper::run($argv));
exit(call_user_func(function (string ...$argv): int {
$result = 1;
$maxTries = ($_SERVER['MAX_TRIES'] ?? null) ?? ($_ENV['MAX_TRIES'] ?? null);
$maxTries = is_numeric($maxTries) ? intval($maxTries) : 1;
for ($try = 0; $try < $maxTries; $try++) {
$result = SatPysScraper::run($argv);
if (0 === $result) {
break;
}
}
return $result;
}, ...$argv));
9 changes: 9 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ versión, aunque sí su incorporación en la rama principal de trabajo. Generalm

## Listado de cambios

### Versión 3.0.2 2024-10-17

A la herramienta `bin/sat-pys-scraper` se le puede definir un número máximo de ejecuciones en la
variable de entorno `MAX_TRIES`, de forma predeterminada usa el valor `1`.
Con este cambio se intenta resolver el problema de error `500 Internal Server Error` de la
aplicación de Productos y Servicios del SAT.

En el flujo de trabajo `system.yml` en el trabajo `system-tests` se configura `MAX_TRIES` a `5`.

### Versión 3.0.1 2024-10-15

La aplicación del SAT devuelve un error 500 frecuentemente (1 de cada 3 veces) desde 2024-07-15.
Expand Down

0 comments on commit 6631d87

Please sign in to comment.