perf: client http rpc and rpcHttp support pure string input and response - #216
Open
xinatcg wants to merge 1 commit into
Open
perf: client http rpc and rpcHttp support pure string input and response#216xinatcg wants to merge 1 commit into
xinatcg wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the RPC methods to support pure string inputs and outputs, reducing JSON serialization overhead when raw data is used.
- Extend
RpcResponse.payloadto acceptstringas well asobject - Add
rawInput/rawOutputflags torpcandrpcHttpKeymethods - Adjust serialization/deserialization to conditionally parse or pass strings directly
Comments suppressed due to low confidence (4)
packages/nakama-js/client.ts:1742
- The
rpcmethod signature was extended withrawInputandrawOutputflags but the JSDoc comment above it wasn’t updated. Consider documenting these new parameters to explain their purpose and default values.
async rpc(session: Session, id: string, input: object | string, rawInput: boolean = false, rawOutput: boolean = false): Promise<RpcResponse> {
packages/nakama-js/client.ts:1757
- The
rpcHttpKeymethod signature now includesrawInputandrawOutputbut its JSDoc remains generic. Please update the doc comment to describe how these flags affect input serialization and response parsing.
async rpcHttpKey(httpKey: string, id: string, input?: object | string, rawInput: boolean = false, rawOutput: boolean = false): Promise<RpcResponse> {
packages/nakama-js/client.ts:1747
- This branch introduces conditional serialization logic for raw vs. JSON inputs. Consider adding unit tests to cover both
rawInput = trueandrawInput = falsescenarios to ensure correct behavior.
const inputStr = rawInput ? input as string : JSON.stringify(input);
packages/nakama-js/client.ts:1765
- The catch block simply rethrows the error without adding context. You can remove the
.catchentirely and let the promise propagate, or enhance error handling with additional diagnostics if needed.
}).catch((err: any) => {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#215