Local Development & Testing
Prerequisites
Concepts: how Defer works
Ensure to be fluent with Defer’s Concepts before proceeding with this page.
Local Development
The good news is that Defer works locally by default; without a specific command.
How?
Locally, background functions run in the background leveraging the Promise API, providing a behavior similar to production environments, with some limitations.
We don’t recommend setting a DEFER_TOKEN
locally. By doing so, all calls to
your background functions will run on the Defer Platform, preventing you from
debugging locally.
Development Limitations
Defer relies on the Promise API to execute background functions locally; it means that all executions are bound to the parent process and will be canceled if the parent process (ex: local server) crashed or is stopped.
@defer/client
supports the following feature locally:
Feature | Local support | Details |
---|---|---|
Immediate execution | ✅ | |
defer() - concurrency option | ✅ | |
defer() - maxDuration option | ❌ | |
defer() - retry option | ❌ | |
defer() - maxConcurrencyAction option | ❌ | |
cancelExecution() | ✅ | The state of the execution is updated to canceled but the execution will continue upon completion. |
awaitResult() | ✅ | |
assignOptions() options | ✅ | Long delays might likely result in cancellation upon your local server termination |
rescheduleExecution() | ✅ | |
delay() - Delayed execution | ✅ | Long delays might likely result in cancellation upon your local server termination |
defer.cron() | ❌ | CRONs do not get scheduled locally. You can still test them like regular defer functions though. |
Troubleshooting
Was this page helpful?