Skip to content

Commit

Permalink
#56 notes for cancellation support
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm committed Dec 31, 2020
1 parent 2c22cad commit 54d5e99
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/example-chat-system/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {ChatServiceClient, IChatServiceClient} from "./protos/service-chat.clien
import {TerminalIO} from "./terminal-io";


// TODO #56 UnhandledPromiseRejectionWarning
// when server dies while client is running
// TODO #56 fix UnhandledPromiseRejectionWarning when server dies while client is running
// TODO #56 fix net::ERR_INCOMPLETE_CHUNKED_ENCODING in browser when using a deadline in browser (this seems like a server issue)



main(
Expand Down
17 changes: 16 additions & 1 deletion packages/example-chat-system/server-alt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {ChatEvent, JoinRequest, PostRequest, PostResponse} from "./protos/servic
import {chatServiceDefinition, IChatService} from "./protos/service-chat.grpc-server";


// TODO UnhandledPromiseRejectionWarning - see client-alt.ts
// TODO fix UnhandledPromiseRejectionWarning - see client-alt.ts
// TODO fix net::ERR_INCOMPLETE_CHUNKED_ENCODING


const host = '0.0.0.0:5000';
Expand All @@ -12,6 +13,20 @@ const host = '0.0.0.0:5000';
const service: IChatService = {

join(call: grpc.ServerWritableStream<JoinRequest, ChatEvent>) {


// this is triggered when client-provided deadline is exceeded.
// client receives a 504 gateway timeout.
//
// with our grpc-backend however, we get a net::ERR_INCOMPLETE_CHUNKED_ENCODING in the browser.
// our grpc-backend does not handle timeout correctly. probably tries to write trailers where
// it shouldn't.
//
// call.on('cancelled', args => {
// console.log("cancelled", args); // args is "deadline" if cancelled by deadline
// });


let e: any = new Error();
e.code = grpc.status.UNIMPLEMENTED;
e.details = 'not implemented';
Expand Down

0 comments on commit 54d5e99

Please sign in to comment.