mirror of https://github.com/grpc/grpc-node.git
grpc-js: Improve tracing around sending data
This commit is contained in:
parent
6994f1b1df
commit
4bc642456b
|
@ -246,9 +246,7 @@ export class Http2CallStream extends Duplex implements Call {
|
||||||
private tryPush(messageBytes: Buffer | null): void {
|
private tryPush(messageBytes: Buffer | null): void {
|
||||||
if (this.isReadFilterPending) {
|
if (this.isReadFilterPending) {
|
||||||
this.trace(
|
this.trace(
|
||||||
'[' +
|
'unfilteredReadMessages.push message of length ' +
|
||||||
this.callNumber +
|
|
||||||
'] unfilteredReadMessages.push message of length ' +
|
|
||||||
(messageBytes && messageBytes.length)
|
(messageBytes && messageBytes.length)
|
||||||
);
|
);
|
||||||
this.unfilteredReadMessages.push(messageBytes);
|
this.unfilteredReadMessages.push(messageBytes);
|
||||||
|
@ -422,10 +420,15 @@ export class Http2CallStream extends Duplex implements Call {
|
||||||
if (!this.pendingWriteCallback) {
|
if (!this.pendingWriteCallback) {
|
||||||
throw new Error('Invalid state in write handling code');
|
throw new Error('Invalid state in write handling code');
|
||||||
}
|
}
|
||||||
|
this.trace(
|
||||||
|
'sending data chunk of length ' +
|
||||||
|
this.pendingWrite.length +
|
||||||
|
' (deferred)'
|
||||||
|
);
|
||||||
stream.write(this.pendingWrite, this.pendingWriteCallback);
|
stream.write(this.pendingWrite, this.pendingWriteCallback);
|
||||||
}
|
}
|
||||||
if (this.pendingFinalCallback) {
|
if (this.pendingFinalCallback) {
|
||||||
this.trace('calling end() on HTTP/2 stream');
|
this.trace('calling end() on HTTP/2 stream (deferred)');
|
||||||
stream.end(this.pendingFinalCallback);
|
stream.end(this.pendingFinalCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,9 +517,13 @@ export class Http2CallStream extends Duplex implements Call {
|
||||||
this.trace('write() called with message of length ' + chunk.message.length);
|
this.trace('write() called with message of length ' + chunk.message.length);
|
||||||
this.filterStack.sendMessage(Promise.resolve(chunk)).then(message => {
|
this.filterStack.sendMessage(Promise.resolve(chunk)).then(message => {
|
||||||
if (this.http2Stream === null) {
|
if (this.http2Stream === null) {
|
||||||
|
this.trace(
|
||||||
|
'deferring writing data chunk of length ' + message.message.length
|
||||||
|
);
|
||||||
this.pendingWrite = message.message;
|
this.pendingWrite = message.message;
|
||||||
this.pendingWriteCallback = cb;
|
this.pendingWriteCallback = cb;
|
||||||
} else {
|
} else {
|
||||||
|
this.trace('sending data chunk of length ' + message.message.length);
|
||||||
this.http2Stream.write(message.message, cb);
|
this.http2Stream.write(message.message, cb);
|
||||||
}
|
}
|
||||||
}, this.handleFilterError.bind(this));
|
}, this.handleFilterError.bind(this));
|
||||||
|
@ -525,6 +532,7 @@ export class Http2CallStream extends Duplex implements Call {
|
||||||
_final(cb: Function) {
|
_final(cb: Function) {
|
||||||
this.trace('end() called');
|
this.trace('end() called');
|
||||||
if (this.http2Stream === null) {
|
if (this.http2Stream === null) {
|
||||||
|
this.trace('deferring calling end() on HTTP/2 stream');
|
||||||
this.pendingFinalCallback = cb;
|
this.pendingFinalCallback = cb;
|
||||||
} else {
|
} else {
|
||||||
this.trace('calling end() on HTTP/2 stream');
|
this.trace('calling end() on HTTP/2 stream');
|
||||||
|
|
Loading…
Reference in New Issue