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

Node: CustomCommand with an unmatched decoder won't throw an error #2119

Closed
adarovadya opened this issue Aug 12, 2024 · 2 comments
Closed

Node: CustomCommand with an unmatched decoder won't throw an error #2119

adarovadya opened this issue Aug 12, 2024 · 2 comments
Assignees
Labels
bug Something isn't working node Node.js wrapper
Milestone

Comments

@adarovadya
Copy link
Collaborator

Describe the bug

An error will occur if the string decoder is used with commands that return only bytes as a response. We wont get an error the command will run forever.

Expected Behavior

get an error

Current Behavior

the command will not return a response

Reproduction Steps

expect(await client.customCommand(["DUMP", key], {decoder: Decoder.Bytes,} )).toThrowError();

Possible Solution

No response

Additional Information/Context

No response

Client version used

Engine type and version

OS

ubuntu

Language

TypeScript

Language Version

Cluster information

No response

Logs

No response

Other information

No response

@adarovadya adarovadya added the bug Something isn't working label Aug 12, 2024
@adarovadya adarovadya added this to the GA milestone Aug 12, 2024
@adarovadya adarovadya modified the milestones: GA, node-GA Aug 12, 2024
@adarovadya adarovadya moved this to TODO bug fixes in Valkey-GLIDE - internal Aug 12, 2024
@adarovadya adarovadya self-assigned this Aug 12, 2024
@yipin-chen
Copy link
Collaborator

I also observed the same issue in transaction test while working on DUMP and RESTORE commands.
If the user forgets to specify Decoder.Bytes as an argument in client.exec while trying to use DUMP, the test will either hang in VS Code terminal or fail from MAC terminal. We should throw the error and prevent the hanging.

Here is the snapshot of the codes, without Decoder.Bytes: (can also reference to PR #2126)

                let response =
                    client instanceof GlideClient
                        ? await client.exec(new Transaction().dump(key1))
                        : await client.exec(new ClusterTransaction().dump(key1));
                expect(response?.[0]).not.toBeNull();
                data = response?.[0] as GlideString;

Here is the output from MAC terminal:

GlideClient › dump and restore test_1

    invalid utf-8 sequence of 1 bytes from index 10

      656 |                             ) as T;
      657 |                         } else {
    > 658 |                             resolveAns = valueFromSplitPointer(
          |                                                               ^
      659 |                                 resolveAns.high!,
      660 |                                 resolveAns.low!,
      661 |                                 stringDecoder,

      at promiseCallbackFunctions.<computed> (src/BaseClient.ts:658:63)
      at GlideClient.processResponse (src/BaseClient.ts:549:13)
      at GlideClient.handleReadData (src/BaseClient.ts:514:22)
      at Socket.<anonymous> (src/BaseClient.ts:598:40)
      
GlideClient › dump and restore test_1

    thrown: "Exceeded timeout of 50000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      5285 |     );
      5286 |
    > 5287 |     it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
           |                                                            ^
      5288 |         "dump and restore test_%p",
      5289 |         async (protocol) => {
      5290 |             await runTest(async (client: BaseClient) => {

      at node_modules/jest-each/build/bind.js:45:11
          at Array.forEach (<anonymous>)
      at runBaseTests (tests/SharedTests.ts:5287:60)
      at tests/GlideClient.test.ts:1248:17
      at Object.<anonymous> (tests/GlideClient.test.ts:50:9)

@adarovadya
Copy link
Collaborator Author

#2182
Warping the valueFromSplitPointer rust function with try-cache and throw exception if the encoding is not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node Node.js wrapper
Projects
Status: Done
Development

No branches or pull requests

3 participants