Use perform_now in test inline! mode - #176
Merged
alachaum merged 6 commits intoJul 13, 2026
Merged
Conversation
inline! is meant to run an enqueued job as the real server would. These specs pin three properties that hold when inline execution happens at the universal backend point (Backend::MemoryTask.create), through which every enqueue path funnels: - Execution coverage: perform_async, perform_at/perform_in, the instance #schedule method, and batch children (enqueued via #schedule) all run. - Error hooks: a raising job triggers the on_error hook, like the server path does via WorkerHandler.with_worker_handling. - Context fidelity: the worker runs with a task_id, as assigned by the backend and read by app logging/instrumentation. Only perform_async had integration coverage; the batch spec drains a fake! queue manually rather than running inline!. Pinning these guards against a refactor that relocates inline execution onto a narrower path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Originally raised in: #173
The test
inline!mode is expected to run jobs immediately. The problem is that this immediate execution is implemented in the create task action on the backend (MemoryTask), which is invoked while enqueuing the job.Since the job is executed while being enqueued, the server middlewares run inside the client middlewares. This means the client middleware may leave dangling locks that the server middlewares would normally clean, thus preventing successive jobs from running in the case of the
unique_jobextension.Here is a typical example:
This PR addresses this issue by doing the following:
perform_nowruns the client middlewares on top of the server middlewares. This ensures the full worker lifecycle is respected.inline!execution in the create action of the backend (MemoryTask)perform_asynctoperform_nowwhen testinline!mode is enabled