Laravel PHP, Rust, and Go: what happens when the queue write fails?

The same validated export request runs on Laravel PHP, Rust, and Go. A queue insert failure after commit exposes a difference that the happy path hides.
Use one contract and introduce one failure
Laravel released its first full-stack Rust beta on December 1, 2026.
Laravel released its first full-stack Go beta on December 2, 2026.
This comparison pins Laravel PHP 13.45.0 on PHP 8.5.5, Laravel Rust 0.1.6 on rustc 1.99.0, and Laravel Go 0.1.2 on Go 1.27.0.
Each app accepts JSON at POST /api/exports. A valid title creates one export row and queues one job carrying its ID. An empty title returns 422 and adds neither row. A fixture-only error after dispatch registration returns 500 and rolls back both effects. The normal request returns 201 and leaves one row in each table.
The fourth request injects a queue outage with a SQLite BEFORE INSERT trigger on jobs. It makes the job write fail after the export transaction commits. The fixture uses a designated title to force rollback before commit. That branch exists only in the test applications.
PHP marks dispatch for after commit
The PHP handler validates a request array, inserts the export through the query builder, and gives a ShouldQueue job the returned integer ID. The route maps database errors through Laravel’s exception handler.
In PHP, afterCommit explicitly defers this job until the active transaction commits. For this fixture the default database connection and the job store both use SQLite, but the job insert still happens after the export transaction.
Route::post('/api/exports', function (Request $request) {
$input = $request->validate(['title' => 'required|string|max:120']);
$id = DB::transaction(function () use ($input) {
$id = DB::table('exports')->insertGetId(['title' => $input['title']]);
GenerateExport::dispatch($id)->afterCommit();
if ($input['title'] === 'rollback-fixture') {
throw new RuntimeException('fixture rollback');
}
return $id;
});
return response()->json(['id' => $id], 201);
});Rust extracts validated input and propagates the error
The Rust input struct uses the laravel::input attribute and declares the title rule with validate attributes. The handler gets Valid<ExportInput>. The query builder binds the title and returns the generated integer ID. The fixture uses an upstream test job as the dispatch probe and never runs its worker.
In Rust, the Valid extractor supplies an input struct to the async handler. The transaction scope used by db::transaction governs dispatch, and a queue push error after commit is returned even though the database has committed the row.
The beta’s SQL API also rejected my first test helper, which built a count query with format!. The test now uses two fixed SQL literals. This is a useful distinction between the safety afforded by the API boundary and what an integration test can establish about a failed side effect.
async fn store(Valid(input): Valid<ExportInput>) -> laravel::Result<(StatusCode, Json<Value>)> {
let id = db::transaction(async |_| {
let id = db::table("exports")
.insert_get_id(laravel::db::values! { title: input.title.as_str() }, "id")
.await?;
ProcessPodcast::new(id).dispatch().await?;
if input.title == "rollback-fixture" {
return Err(laravel::abort_with(500, "fixture rollback"));
}
Ok(id)
}).await?;
Ok((StatusCode::CREATED, Json(serde_json::json!({"id": id}))))
}Go carries the transaction in context.Context
The Go input is a struct with a JSON field tag and a Rules method that assigns the Required and Max rules. The handler calls r.Validate and returns validation errors through web.Fail. The model binder populates the ID on the record passed to model.Create.
In Go, the transaction passes a context to its callback. Both model.Create and queue.Dispatch receive that context. A post-commit push failure is reported by the framework while the transaction call returns success.
Passing the request context where the transaction context is required changes which work belongs to the transaction. Preserve the callback context through helpers that write to the database or register work. Add a rollback case that reaches those helpers.
func storeExport(r *web.Request) *web.Response {
input, err := r.Validate[exportInput]()
if err != nil {
return web.Fail(err)
}
record := exportRecord{Title: input.Title}
err = db.Transaction(r, func(ctx context.Context) error {
if err := model.Create(ctx, &record); err != nil {
return err
}
if _, err := queue.Dispatch(ctx, generateExport{ExportID: record.ID}); err != nil {
return err
}
if input.Title == "rollback-fixture" {
return errors.New("fixture rollback")
}
return nil
})
if err != nil {
return web.Fail(err)
}
return web.JSON(map[string]int64{"id": record.ID}).WithStatus(201)
}A 500 can leave a row and a 201 can leave no job
After the queue insert fails, all three retain the second export and still have just one job in the table. PHP and Rust return HTTP 500 in these handlers. Go returns HTTP 201 and reports the after-commit failure. The response alone cannot tell an operator whether there is work left to recover.
Read the fourth result relative to the preceding successful request. An export row can exist without a queued job even though the handler followed the documented commit boundary. PHP callers that blindly retry on 500 can create a second export. A Go caller can see 201 while the server needs to reconcile a missing job.
If the API promises that every accepted export will eventually run, persist a pending status or an outbox row with the export in the same transaction. Publish from a separate relay, retry with a stable export ID, and make the worker’s effect idempotent. A crash after publication and before recording delivery can cause the relay to publish twice. Design the consumer for that case.
These tests invoke the real route handlers through each framework’s in-process HTTP entry point and use its actual SQLite database queue driver. They do not start a queue worker, exercise a network broker, test throughput, or establish that a given application can migrate unchanged.
Pick the runtime by operating the feature
I recommend picking a stack by running the same request and failure probes with the database, queue driver, and deployment model the new application will actually use.
For a new app, start with PHP when the team already runs PHP workers and depends on PHP packages. Prototype Go when the team already operates Go services and wants to compose with net/http. Prototype Rust when the team wants the typed request and SQL APIs and can support the Rust build and deployment toolchain. Treat both new frameworks as betas and pin their dependencies in CI.
Deploy a web process and a separate worker in the pilot. Verify that migrations run before either needs new columns, that the worker can drain jobs across a release, and that alerts distinguish a failed request from a failed publish after commit. Measure request latency, queue age, and duplicate effects before comparing throughput.
For an existing PHP application, I recommend keeping PHP as the default until a candidate proves compatibility with the contracts the application depends on. Include auth sessions, route and middleware behavior, schema migrations, serialized jobs, retries, and packages in that review.
For a staged migration, give each runtime its own queue or use a versioned message contract that both consumers implement. Keep legacy workers alive long enough to drain their existing payloads. Treat a shared queue table name or Redis backend as a transport choice and verify payload compatibility separately.
Reproduce the examples
The PHP fixture and lockfile, the Go test, and the Rust test patch with instructions to reproduce all four cases.
Download the source and tests (.zip)
