Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions yarn-project/p2p/src/services/reqresp/reqresp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,16 +666,19 @@ export class ReqResp {
errorStatus = e.status;
}

const sendErrorChunk = this.sendErrorChunk(errorStatus);

// Return and yield the response chunk
await pipe(
stream,
async function* (_source: any) {
yield* sendErrorChunk;
},
stream,
);
if (stream.status === 'open') {
const sendErrorChunk = this.sendErrorChunk(errorStatus);
// Return and yield the response chunk
await pipe(
stream,
async function* (_source: any) {
yield* sendErrorChunk;
},
stream,
);
} else {
this.logger.debug('Stream already closed, not sending error response', { protocol, err: e, errorStatus });
}
} finally {
//NOTE: All other status codes indicate closed stream.
//Either graceful close (closed/closing) or forced close (aborted/reset)
Expand Down