Skip to content

Commit 8374364

Browse files
authored
Merge pull request #2592 from murgatroid99/example_cancellation_fix
Cancellation example: corrected information
2 parents f7d9baa + 2003c88 commit 8374364

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

examples/cancellation/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
This example shows how clients can cancel in-flight RPCs by cancelling the
44
call object returned by the method invocation. The client will receive a status
5-
with code `CANCELLED` and the server handler's call object will emit a
6-
`'cancelled'` event.
5+
with code `CANCELLED` and the server handler's call object will emit either a
6+
`'cancelled'` event or an `'end'` event.
77

88
## Start the server
99

examples/cancellation/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ function bidirectionalStreamingEcho(call) {
3838
console.log(`echoing message "${message}"`);
3939
call.write({message: message});
4040
});
41+
// Either 'end' or 'cancelled' will be emitted when the call is cancelled
4142
call.on('end', () => {
43+
console.log('server received end event')
4244
call.end();
4345
});
4446
call.on('cancelled', () => {
45-
console.log('received cancelled event');
47+
console.log('server received cancelled event');
4648
});
4749
}
4850

0 commit comments

Comments
 (0)