Skip to content
LaravelBlog

Livewire: Support minute durations for wire:poll

LaravelBlogBot
LaravelBlogBot

Contributed by joshhanley

Part of the livewire v4.4.7 release

Livewire 4 closes a quiet but expensive gap in the wire:poll duration parser. Until now, minute-based durations like wire:poll.10m were not recognised at all. The parser only understood ms and s suffixes, so any m modifier silently fell back to the default two-second interval — a dashboard widget asked to refresh every ten minutes was actually polling every two seconds, 300 times more often than intended. PR #10427 adds first-class support for minute durations, documents the new modifier, and locks the behaviour in with a browser test. Its companion PR (#10426) adds a console warning for any duration modifier that still cannot be parsed, so silent fallbacks like this one can't hide again. If you are upgrading from v3.8.10, here is what changes and what to double-check.

What changed

The duration extraction in js/directives/wire-poll.js gained a third branch for minutes:

let durationInMinutesString = modifiers.find(mod => mod.match(/([0-9]+)m/))

// ...
} else if (durationInMinutesString) {
    durationInMilliSeconds = Number(durationInMinutesString.replace('m', '')) * 60 * 1000
}

Match order matters here: ms is tested before m, so a 15000ms modifier is read as fifteen seconds rather than 15,000 minutes. The supported suffixes are now:

<div wire:poll.1m>      <!-- every 1 minute (60,000 ms) -->
<div wire:poll.15s>     <!-- every 15 seconds -->
<div wire:poll.15000ms> <!-- every 15,000 milliseconds -->

Both docs/wire-poll.md and docs/polling.md were updated with the same example plus a new .[number]m row in the modifier reference table.

Why it matters

The old failure mode was silent and inverted: an unsupported duration made polling more aggressive, not less. Because an unrecognised modifier returned the default duration, .10m effectively meant "every 2 seconds". For a single widget, that is the difference between 43,200 requests per day and 144:

Interval Requests per day (one widget)
Every 2s (old fallback for .10m) 43,200
Every 10m (new behaviour) 144

Multiply that by a handful of dashboard widgets and a dozen open browser tabs, and the accidental load becomes substantial. Minute support gives wire:poll a sane middle ground between second-scale refreshes and "just use a scheduled job", which is exactly what widgets like status banners, notification counters, or slowly changing metrics need.

Upgrade impact: audit every m modifier

This PR ships on the 4.x branch, so v3.8.10 keeps the old behaviour — the change arrives when you move to Livewire 4. Three scenarios to check:

  1. You used m intending minutes. Good news: it now works. Your polls will genuinely slow down, server load will drop, and your UI will visibly update less often. If any screen quietly depended on the accidental two-second cadence, spell it out explicitly with .2s.
  2. You used m intending milliseconds. This is the dangerous one. .500m used to poll every 2 seconds; in v4 it polls every 500 minutes — over eight hours. Convert those to the ms suffix:
<div wire:poll.500ms="refreshFeed"> <!-- every 500 ms, not 500 minutes -->
  1. You never used m. Nothing changes; the s and ms paths are untouched.

A safety net for typos

PR #10426, which this change accompanies, warns in the browser console when a duration modifier cannot be parsed. The default fallback still exists, but it is no longer invisible: a typo like wire:poll.10min or an uppercase .10M (the parser only matches lowercase m) surfaces a warning during development instead of degrading into a two-second poll in production.

Tests and documentation

The PR adds a Livewire browser test that stubs window.setInterval, starts a component using wire:poll.1m="poll", and asserts the interval receives exactly 60000 milliseconds before verifying that the poll actually fires. That guards both the minutes-to-milliseconds conversion and the modifier-matching order against future regressions.

Takeaways

  • wire:poll.[number]m now means minutes; .10m polls every ten minutes instead of silently every two seconds.
  • s and ms behaviour is unchanged, and ms still wins over m when both could match.
  • Audit existing templates for m modifiers before upgrading: intended minutes are now correct, while intended milliseconds must become ms.
  • Unsupported durations now trigger a console warning (PR #10426) rather than failing silently.
  • Only lowercase m is recognised; variants like min or M remain invalid and will warn.

Sources

More from this release

Related Articles