You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(s2-rm): answer a PEBC revoke only after REVOKED (#122) - #135
Tested with the unit tests: all 814 pass, and the 5 new session tests fail without the fix.
I checked the wiring of the We.Positive flow against this change: s2-pebc's output goes back into s2-rm, so a valid revoke still gets OK. Skip instruction status updates doesn't hold back REVOKED.
A flow that handles PEBC instructions without s2-pebc now gets PERMANENT_ERROR after 2 seconds, unless it sends InstructionStatus with REVOKED. The changelog says so.
s2-rm answered every revoke of a PEBC instruction with OK, also when
s2-pebc no longer held it. EN 50491-12-2 §9.3.6 allows OK only once the
instruction is REVOKED, and a rejection otherwise.
Only s2-pebc knows which instructions it holds, also from an earlier
session. The session now forwards a PEBC revoke and answers OK when
the instruction is reported REVOKED, or PERMANENT_ERROR when that
doesn't happen within 2 seconds. A flow that handles PEBC without
s2-pebc gets OK by sending InstructionStatus REVOKED.
Closes#122.
This PR addresses #122 by making the shared S2 session wait for REVOKED before acknowledging a PEBC revoke, rather than returning OK merely because it was forwarded.
Changes:
Returns OK after REVOKED, or PERMANENT_ERROR after a two-second timeout.
Adds tests for confirmation, timeout, repeated revokes, and disposal.
Documents the required status response for custom PEBC flows.
File
Description
test/lib/session.test.ts
Adds coverage for deferred PEBC revoke replies and cleanup.
src/lib/s2/session.ts
Tracks pending revokes, handles confirmation and timeout, and clears timers on disposal.
docs/S2_REFERENCE.md
Explains PEBC revoke confirmation and timeout behavior.
CHANGELOG.md
Records the fix and requirements for flows without s2-pebc.
A revoke resent with the same message_id while the first waited for
REVOKED replaced its pending entry but left the first timer running.
The CEM then got OK followed by PERMANENT_ERROR, and the timer
survived dispose(). Keep the first entry instead.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The duplicate guard drops completed revoke results, allowing a retransmission after REVOKED to be forwarded again and return PERMANENT_ERROR despite the original request succeeding.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Replay completed revoke results to prevent duplicate forwarding
src/lib/s2/session.ts:488
The duplicate guard stops working once REVOKED removes the pending entry and sends OK. If the CEM retransmits the same message_id before receiving that reply, the revoke is forwarded again; s2-pebc no longer holds the instruction, so the timer returns PERMANENT_ERROR for a request that succeeded. Retain and replay completed reception results without forwarding the request again, and add a test for a resend after REVOKED.
On the "previously missed issue" (a revoke resent after it was answered): leaving this out. EN 50491-12-2 defines no retransmission of a message, only the retry after TEMPORARY_ERROR, which a revoke never gets here. The session does not deduplicate any other message either. Replaying answered message_ids would need a cache for every message type, which is a separate change if a CEM turns out to resend.
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
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.
Closes #122.
Tested with the unit tests: all 814 pass, and the 5 new session tests fail without the fix.
I checked the wiring of the We.Positive flow against this change: s2-pebc's output goes back into s2-rm, so a valid revoke still gets OK. Skip instruction status updates doesn't hold back REVOKED.
A flow that handles PEBC instructions without s2-pebc now gets PERMANENT_ERROR after 2 seconds, unless it sends
InstructionStatuswithREVOKED. The changelog says so.