[Polyglot Experience] Storing a Python list in a map and reading it on the NodeJS side fails
Closed this issue · 4 comments
Storing a Python list in a map and accessing that in the NodeJS client side causes a NodeJS exception. The same list can be accessed OK from the Java client.
Using Hazelcast 4.1.1.
Reproducer, Python side (Python client 4.0):
hz = HazelcastClient()
polyglot_map = hz.get_map("polyglot").blocking()
polyglot_map.put("python-list", [1, 2, 3])
Python project is at: https://github.com/yuce/hazelcast-polyglot-experience/tree/main/python-project
NodeJS side (NodeJS client 4.1):
(async () => {
const client = await Client.newHazelcastClient();
const polyglotMap = await client.getMap("polyglot");
const pythonList = await polyglotMap.get("python-list");
console.log(`pythonList: ${pythonList}`);
})();
The exception i get is:
Error running main TypeError: Cannot read property 'read' of undefined
at SerializationServiceV1.toObject (/home/yuce/Work/hazelcast/blog_post/polyglot-hazelcast-experience/nodejs-project/node_modules/hazelcast-client/lib/serialization/SerializationService.js:85:27)
at MapProxy.toObject (/home/yuce/Work/hazelcast/blog_post/polyglot-hazelcast-experience/nodejs-project/node_modules/hazelcast-client/lib/proxy/BaseProxy.js:102:54)
at /home/yuce/Work/hazelcast/blog_post/polyglot-hazelcast-experience/nodejs-project/node_modules/hazelcast-client/lib/proxy/MapProxy.js:477:25
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async main (/home/yuce/Work/hazelcast/blog_post/polyglot-hazelcast-experience/nodejs-project/server.js:96:24)
at async /home/yuce/Work/hazelcast/blog_post/polyglot-hazelcast-experience/nodejs-project/server.js:134:9
NodeJS project is at: https://github.com/yuce/hazelcast-polyglot-experience/tree/main/nodejs-project
Java client can correctly load the same Python list (Java client 4.1.1):
HazelcastInstance hz = HazelcastClient.newHazelcastClient();
IMap<String, Object> polyglotMap = hz.getMap("polyglot");
Object pythonList = polyglotMap.get("python-list");
System.out.printf("pythonList: %s%n", pythonList);
Java project is at: https://github.com/yuce/hazelcast-polyglot-experience/tree/main/java-project
@yuce could also describe how lists are serialized in Python? Namely, which serializer is used for the list.
@puzpuzpuz Thanks for the quick fix!