Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReqResp does not return null in any case #2058

Merged
merged 1 commit into from
Feb 18, 2021
Merged

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented Feb 18, 2021

reqResp request never returns null. For protocols with multiple responses, returns an array possibly empty. For single response protocols, returns 1 response or throw an error. Current types added unnecessary complexity for an out-of-spec situation

reqResp request never return null. For protocols with multiple responses, return an array possibly empty. For single response protocols, return 1 response or throw an error. Current types added unnecessary complexity for an out-of-spec situation
@github-actions github-actions bot added the scope-networking All issues related to networking, gossip, and libp2p. label Feb 18, 2021
@codeclimate
Copy link

codeclimate bot commented Feb 18, 2021

Code Climate has analyzed commit 6be3fbf and detected 0 issues on this pull request.

View more on Code Climate.

return async (source) => {
if (isRequestSingleChunk(method)) {
for await (const response of source) {
return response as T;
}
return null;
throw new RequestInternalError({code: RequestErrorCode.EMPTY_RESPONSE});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

methods that isRequestSingleChunk must return exactly 1 response chunk

@dapplion dapplion merged commit 25ac0d1 into master Feb 18, 2021
@dapplion dapplion deleted the dapplion/reqresp-null branch February 18, 2021 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope-networking All issues related to networking, gossip, and libp2p.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants