Skip to content

Commit ce2a212

Browse files
committed
Update cancellation.md
1 parent 9437962 commit ce2a212

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

docs/specification/basic/utilities/cancellation.md

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,52 +29,49 @@ When a party wants to cancel an in-progress request, it sends a `notifications/c
2929

3030
## Behavior Requirements
3131

32-
Both clients and servers MUST follow these requirements when handling cancellation:
33-
34-
1. Cancellation notifications MUST only reference requests that:
32+
1. Cancellation notifications **MUST** only reference requests that:
3533
- Were previously issued in the same direction
3634
- Are believed to still be in-progress
37-
38-
2. The `initialize` request MUST NOT be cancelled by clients
39-
40-
3. Receivers of cancellation notifications SHOULD:
35+
2. The `initialize` request **MUST NOT** be cancelled by clients
36+
3. Receivers of cancellation notifications **SHOULD**:
4137
- Stop processing the cancelled request
4238
- Free associated resources
4339
- Not send a response for the cancelled request
44-
45-
4. Receivers MAY ignore cancellation notifications if:
40+
4. Receivers **MAY** ignore cancellation notifications if:
4641
- The referenced request is unknown
4742
- Processing has already completed
4843
- The request cannot be cancelled
44+
5. The sender of the cancellation notification **SHOULD** ignore any response to the request that arrives afterward
4945

5046
## Timing Considerations
5147

52-
Due to network latency, cancellation notifications may arrive after request processing has completed. Both parties MUST handle these race conditions gracefully:
48+
Due to network latency, cancellation notifications may arrive after request processing has completed, and potentially after a response has already been sent.
49+
50+
Both parties **MUST** handle these race conditions gracefully:
5351

5452
```mermaid
5553
sequenceDiagram
56-
participant Client
57-
participant Server
58-
59-
Client->>Server: Request (ID: 123)
60-
Note over Server: Processing starts
61-
Client--)Server: notifications/cancelled (ID: 123)
62-
Note over Server: Processing may<br/>complete before<br/>cancellation arrives
63-
opt If not completed
64-
Note over Server: Stop processing
65-
end
54+
participant Client
55+
participant Server
56+
57+
Client->>Server: Request (ID: 123)
58+
Note over Server: Processing starts
59+
Client--)Server: notifications/cancelled (ID: 123)
60+
alt
61+
Note over Server: Processing may have<br/>completed before<br/>cancellation arrives
62+
else If not completed
63+
Note over Server: Stop processing
64+
end
6665
```
6766

6867
## Implementation Notes
6968

70-
- Servers SHOULD implement timeouts for long-running operations
71-
- Clients SHOULD track pending requests that can be cancelled
72-
- Both parties SHOULD log cancellation reasons for debugging
73-
- UIs SHOULD provide feedback when cancellation is requested
69+
- Both parties **SHOULD** log cancellation reasons for debugging
70+
- Application UIs **SHOULD** indicate when cancellation is requested
7471

7572
## Error Handling
7673

77-
Invalid cancellation notifications SHOULD be ignored without error responses:
74+
Invalid cancellation notifications **SHOULD** be ignored:
7875

7976
- Unknown request IDs
8077
- Already completed requests

0 commit comments

Comments
 (0)