roach-php / core

The complete web scraping toolkit for PHP.

Home Page:https://roach-php.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

time_sleep_until(): Argument #1 ($timestamp) must be greater than or equal to the current time

kolaente opened this issue · comments

Describe the bug

Running a Crawler which yields new requests fails after processing the initialUrls.

Error message:

  time_sleep_until(): Argument #1 ($timestamp) must be greater than or equal to the current time

  at vendor/roach-php/core/src/Scheduling/Timing/SystemClock.php:42
     38▕             return;
     39▕         }
     40▕
     41▕         /** @psalm-suppress UnusedFunctionCall */
  ➜  42▕         \time_sleep_until($date->getTimestamp());
     43▕     }
     44▕ }
     45▕

      +6 vendor frames

  7   app/Jobs/CrawlWebsiteSource.php:33
      RoachPHP\Roach::startSpider("App\Spiders\WebsiteSpider", Object(RoachPHP\Spider\Configuration\Overrides), [Object(App\Models\Source)])
      +21 vendor frames

  29  app/Console/Commands/CrawlSources.php:19
      App\Jobs\CrawlWebsiteSource::dispatch(Object(App\Models\Source))

Reproduction

Example from here: https://roach-php.dev/docs/processing-responses#dispatching-requests

Expected behavior

not crashing

Package versions (please complete the following information):

Setting requestDelay to 0 seems to make it work, but that's not a durable solution.

+1 for this. Package v3.0 is not usable in our set-up. Downgrading to 2.0 fixes it.

Are you able to reproduce this issue reliably?

Should be fixed in the latest release.