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

Make RpcResponse provide the resopnse payload directly #3185

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

lorisleiva
Copy link
Contributor

@lorisleiva lorisleiva commented Sep 1, 2024

This PR reverts some of the changes in the previous stack by making the following key change:

// Before.
type RpcResponse<TResponse = unknown> = {
    readonly json: () => Promise<TResponse>;
    readonly text: () => Promise<string>;
};

// After.
type RpcResponse<TResponse = unknown> = TResponse;

This is because we no longer believe that it is the responsibility of the RPC API to affect the response as text or JSON. This aspect should be encapsulated by the RPC Transport layer, meaning any custom JSON parsing/stringifying will need to be done at the RPC Transport layer.

Note that, we could simply delete the RpcResponse type since it returns its type parameter directly but keeping it makes the code clearer as we will use RpcResponse instead of unknown everywhere in the codebase.

Copy link

changeset-bot bot commented Sep 1, 2024

⚠️ No Changeset found

Latest commit: 4f05c0d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@lorisleiva lorisleiva force-pushed the loris/revert-rpc-response-type branch from 11c2b74 to cf99f67 Compare September 1, 2024 19:17
@lorisleiva lorisleiva marked this pull request as ready for review September 1, 2024 19:24
@lorisleiva lorisleiva force-pushed the loris/remove-temp-fix-479 branch from 216d952 to 75ad8c6 Compare September 2, 2024 15:42
@lorisleiva lorisleiva force-pushed the loris/revert-rpc-response-type branch from cf99f67 to de2bb81 Compare September 2, 2024 15:42
@lorisleiva lorisleiva force-pushed the loris/remove-temp-fix-479 branch from 75ad8c6 to f3051ba Compare September 3, 2024 21:35
@lorisleiva lorisleiva force-pushed the loris/revert-rpc-response-type branch from de2bb81 to e8fc7ad Compare September 3, 2024 21:35
@lorisleiva lorisleiva force-pushed the loris/remove-temp-fix-479 branch from f3051ba to 38241cb Compare September 3, 2024 22:11
@lorisleiva lorisleiva force-pushed the loris/revert-rpc-response-type branch from e8fc7ad to efdef44 Compare September 3, 2024 22:11
@lorisleiva lorisleiva force-pushed the loris/remove-temp-fix-479 branch 2 times, most recently from 54addbf to e36ee23 Compare September 5, 2024 09:20
@lorisleiva lorisleiva force-pushed the loris/revert-rpc-response-type branch from efdef44 to 50e9859 Compare September 5, 2024 09:20
@lorisleiva lorisleiva force-pushed the loris/remove-temp-fix-479 branch from e36ee23 to bf4897c Compare September 6, 2024 11:48
@lorisleiva lorisleiva force-pushed the loris/revert-rpc-response-type branch from 50e9859 to 191c075 Compare September 6, 2024 11:49
Copy link
Collaborator

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

Added via Giphy

Comment on lines -7 to -12
function createMockResponse<T>(jsonResponse: T): RpcResponse<T> {
return {
json: () => Promise.resolve(jsonResponse),
text: () => Promise.resolve(JSON.stringify(jsonResponse)),
};
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this was the clue, all along.

Copy link
Contributor Author

lorisleiva commented Sep 10, 2024

Merge activity

  • Sep 10, 3:48 AM EDT: @lorisleiva started a stack merge that includes this pull request via Graphite.
  • Sep 10, 3:52 AM EDT: Graphite rebased this pull request as part of a merge.
  • Sep 10, 3:53 AM EDT: @lorisleiva merged this pull request with Graphite.

@lorisleiva lorisleiva changed the base branch from loris/remove-temp-fix-479 to graphite-base/3185 September 10, 2024 07:48
@lorisleiva lorisleiva changed the base branch from graphite-base/3185 to master September 10, 2024 07:49
@lorisleiva lorisleiva force-pushed the loris/revert-rpc-response-type branch from 191c075 to 4f05c0d Compare September 10, 2024 07:51
@lorisleiva lorisleiva merged commit e1dfb2c into master Sep 10, 2024
7 checks passed
@lorisleiva lorisleiva deleted the loris/revert-rpc-response-type branch September 10, 2024 07:53
Copy link
Contributor

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants