https://linen.dev logo
d

Dirk Bolte

07/28/2023, 8:25 AM
while working with the new extensions more, had issues, especially in the CI systems, that somehow feels like
afterComplete
are not processed timely. Can it happen that these events are processed after the response was sent and thus even after the next request is matched?
o

Oleg Nenashev

07/28/2023, 8:35 AM
I need to check the code but it is plausible
d

Dirk Bolte

07/28/2023, 8:37 AM
can we somehow create a way to have events processed before the response is sent? e.g. finish all events for a serveevent before sending the response and/or having an extra event for "after" sending the response. With the state extension, I run into race conditions as the next request might rely on the state of the previous one.
o

Oleg Nenashev

07/28/2023, 8:43 AM
It makes sense. As well as both sync and Async after-hooks
👍 1
t

Tom

07/31/2023, 10:17 AM
Yes, that part is necessarily async as Jetty uses non-blocking IO and
afterComplete
only occurs after the response has been fully sent. So there’s no way to make this synchronous unfortunately. Jetty did have a blocking IO connector a few versions ago but they dropped it IIRC. I suggest using
afterMatch
if you can as this is (or should be!) reliably synchronous.
d

Dirk Bolte

07/31/2023, 10:19 AM
is the response already available in
afterMatch
?
t

Tom

07/31/2023, 10:23 AM
The response definition is. Would that work for you?
d

Dirk Bolte

07/31/2023, 10:24 AM
will try - should at least minimize the window then
t

Tom

07/31/2023, 10:24 AM
Wonder if we should consider adding
afterResponseRendered
d

Dirk Bolte

07/31/2023, 10:25 AM
ah right - definition != rendered
would need the rendered version
or, to make it a pair:
beforeComplete
?
t

Tom

07/31/2023, 10:26 AM
I feel like
beforeComplete
is a bit ambiguous i.e. how far before complete are we?
I’m curious why you need the rendered response - is this because you need to be able to capture bits of it to store in state variables?
d

Dirk Bolte

07/31/2023, 10:29 AM
when you e.g. create a new entity in a CRUD API, the response can contain a randomly generated ID. This ID is used in the next GET. One use case of the state extension is to retrieve data based on this ID, therefore I need to have it available for recording a state.
t

Tom

07/31/2023, 10:31 AM
OK, makes sense. I’m looking at adding a new event as we discussed. Think I might call it
beforeResponseSent
as the best place to call it seems to be after response rendering + all other activities have taken place. Does this seem reasonable to you?
d

Dirk Bolte

07/31/2023, 10:32 AM
sounds good. That event would still be async, wouldn't it?
t

Tom

07/31/2023, 11:39 AM
No, at that point we can still do it synchronously
d

Dirk Bolte

07/31/2023, 11:39 AM
nice
t

Tom

07/31/2023, 11:39 AM
It’s the pushing bytes out over the (NIO) network connector that’s async
@Dirk Bolte this look like it’ll do what you want? https://github.com/wiremock/wiremock/pull/2295
d

Dirk Bolte

08/02/2023, 9:00 AM
looks good - will give it a try soon
👍 1
t

Tom

08/02/2023, 10:03 AM
I’ll merge and release it in a new beta build
👍 1