Livewire: Support minute durations for wire:poll
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:
- You used
mintending 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. - You used
mintending milliseconds. This is the dangerous one..500mused to poll every 2 seconds; in v4 it polls every 500 minutes — over eight hours. Convert those to themssuffix:
<div wire:poll.500ms="refreshFeed"> <!-- every 500 ms, not 500 minutes -->
- You never used
m. Nothing changes; thesandmspaths 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]mnow means minutes;.10mpolls every ten minutes instead of silently every two seconds.sandmsbehaviour is unchanged, andmsstill wins overmwhen both could match.- Audit existing templates for
mmodifiers before upgrading: intended minutes are now correct, while intended milliseconds must becomems. - Unsupported durations now trigger a console warning (PR #10426) rather than failing silently.
- Only lowercase
mis recognised; variants likeminorMremain invalid and will warn.