valkey-glide: Node: Unable to handle responses with numeric pointers

Describe the bug

When a response is returned in the Node driver, if it is not referenced with a long pointer an error is thrown from the Rust code stating Failed to convert napi value Undefined into rust type u32.

Expected Behavior

When a response is received and referenced with a numeric pointer the Node Rust driver is able to process and return it.

Current Behavior

2025-02-25T17:06:51.571890Z ERROR logger_core: Decoder - Decoding error: 'Error: Failed to convert napi value Undefined into rust type `u32`'
2025-02-25T17:06:51.573Z	6af46478-8986-4dac-96f5-8fbfb634f9d9	INFO	Error: Decoding error: 'Error: Failed to convert napi value Undefined into rust type `u32`'
    at _GlideClusterClient.processResponse (/var/task/index.js:56443:64)
    at _GlideClusterClient.handleReadData (/var/task/index.js:56354:18)
    at Socket.<anonymous> (/var/task/index.js:56491:47)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
    at Readable.push (node:internal/streams/readable:392:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:191:23)

Reproduction Steps

I’m not 100% sure how the Rust code determines if the pointer should be numeric or long but it seems that running a Transaction on Linux consistently uses a numeric pointer and throws the error.

Possible Solution

It seems that the PointerResponse class is constructed with the number from the message but the high and low values are left as undefined. When this is passed to the value_from_split_pointer function in the glide-rs driver it is unable to process the pointer as there is no high and low value.

Additional Information/Context

No response

Client version used

1.3.0

Engine type and version

Valkey 8.0.1

OS

Linux

Language

TypeScript

Language Version

5.2.2

Cluster information

Using an AWS Elasticache valkey cluster in Multi AZ with 2 shards and 6 nodes.

Logs

No response

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 36 (15 by maintainers)

Most upvoted comments

@Yury-Fridlyand I can confirm I am using the Node 20 Lambda base which use AL2023. The client does load and connect to the Valkey cluster, and makes the request, it’s during the response handling that the error occurs.

@avifenesh I don’t call set for the ipKey outside the transaction. I let the transaction create the key as incr will create the key with a value of 0 if it doesn’t exist. The entire transaction is what’s in the code snippet. If that’s not what you need please let me know.

Thank you

@skelleyton Appreciated a lot! Thank you very much!

Yes, exactly. But your issue is unique, the other users had problems in a much earlier point.

I assigned myself to write some bundling “how to”, so your example will help me help the rest 😃

Just pointing that we have a few users using esbuild, so there is something unique it this case. Please keep me posted.

Thanks I appreciate the help. I think the issue is the way that the inquire package from @protobufjs works. Since it’s not actually a require esbuild is unable to track that require and substitute the bundled code for the require. I will try to get some code up sometime today, going to track this down a bit further first though.

I tested in an AL2023 container and it was able to process responses from Valkey without issue.

@skelleyton Yes I used the Docker. I can set up a lambda and check.

Thanks, I will run some tests in a general AL2023 image as well. I am seeing the issue in both Node 20 and Node 22 containers for Lambda.

@skelleyton Created a repo with a simple example https://github.com/avifenesh/numericIssueRepro Can you please take a look and tell me if you see some differences that should affect the results? And if so, please let me know what to try differently.

Obviously the code means nothing, it is just to reproduce similar behavior.

Thanks for digging into this. I will continue to look on my end to see if anything else stands out to me.