eyre: ignore facts directly after clog

When an application would send multiple facts during a single event, it
was possible for the first fact to trigger a clog, removing the
subscription and sending a quit, but then the second fact still getting
sent out at normal.

Here, we drop any facts for subscriptions we don't have registered in
state, which should only happen in the described case.
This commit is contained in:
fang 2020-10-24 11:45:21 +02:00
parent 235bfbbd2f
commit 26049a3da0
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
2 changed files with 29 additions and 2 deletions

View File

@ -1500,6 +1500,15 @@
?~ channel
:_ state :_ ~
[duct %pass /flog %d %flog %crud %eyre-no-channel >id=channel-id< ~]
:: it's possible that this is a fact emitted directly alongside a fact
:: that triggered a clog & closed the subscription. in that case, just
:: drop the fact.
::
?: ?& ?=(%fact -.sign)
!(~(has by subscriptions.u.channel) request-id)
==
~& [%e %fact-without-subscription channel-id request-id]
[~ state]
:: attempt to convert the sign to json.
:: if conversion succeeds, we *can* send it. if the client is actually
:: connected, we *will* send it immediately.

View File

@ -1875,7 +1875,7 @@
loop-fact(cur +(cur))
:: the next subscription result should trigger a clog
::
=^ results eyre-gate
=^ results1 eyre-gate
%: eyre-take
eyre-gate
now
@ -1922,7 +1922,25 @@
==
==
==
results
:: subsequent subscription updates, which might have gotten sent out during
:: the same event in which a clog triggered, should be silently ignored
::
=^ results2 eyre-gate
%: eyre-take
eyre-gate
now
scry=scry-provides-code
^= take-args
:* wire=/channel/subscription/'0123456789abcdef'/'1'/~nul/two
duct=~[/http-put-request]
^- (hypo sign:eyre-gate)
:- *type
[%g %unto %fact %json !>(`json`[%a [%n '1'] ~])]
==
^= moves
~
==
(weld results1 results2)
::
++ test-born-sends-pending-cancels
::