Open gregcotten opened 2 years ago
I should mention that the new Todo model correctly doesn't get created on the database, which would be much more frightening!
@gregcotten This happens because the actual try await self.save()
does not fail. It is the wrapping transaction that fails, and therefore just causes a ROLLBACK
and propagates the error up the chain. The middleware is not aware of any code that happens after your call to .save()
. The only errors you would be able to catch are errors from other middlewares or actual errors thrown inside the Fluent create
function.
Now whether this behaviour should be changed for transactions, I am not sure about. Let's ask @gwynne
@gwynne and @0xTim interested to hear your feedback. Alternatively would be nice to have another way to await once the transaction succeeds.
Hi there! Using Vapor 4.54.0 and Fluent 4.4.0
I'm having an issue with
AsyncModelMiddleware
and perhaps justModelMiddleware
in general.For simplicity, I've reproduced the issue in the template app that you get from
vapor new
Inside Todo.swift:
In routes:
I made sure to add the middleware in the configure step:
Unfortunately my assertion in TodoMiddleware always fails (no error gets thrown). Is there something I am missing, or is this expected behavior?