redis 4: ERR_INVALID_ARG_TYPE The "chunk" argument must be of type string
See original GitHub issueError
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer. Received type function ([Function])
at validChunk (_stream_writable.js:281:10)
at Socket.Writable.write (_stream_writable.js:316:21)
at RedisSocket.writeCommand (\node_modules\@node-redis\client\dist\lib\client\socket.js:57:130)
at Commander._RedisClient_tick (\node_modules\@node-redis\client\dist\lib\client\index.js:421:64)
at Commander._RedisClient_sendCommand (\node_modules\@node-redis\client\dist\lib\client\index.js:402:82)
at Commander.sendCommand (\node_modules\@node-redis\client\dist\lib\client\index.js:356:93)
at Commander.<computed>.<computed> (\node_modules\@node-redis\client\dist\lib\client\index.js:390:27)
at new RedisAdapter (\node_modules\@socket.io\redis-adapter\dist\index.js:75:28)
at new <anonymous> (\node_modules\@socket.io\redis-adapter\dist\index.js:45:16)
at Namespace._initAdapter (\node_modules\socket.io\dist\namespace.js:40:24)
package.json
"dependencies": {
"@socket.io/redis-adapter": "^7.1.0",
"express": "^4.17.2",
"express-socket.io-session": "^1.3.5",
"redis": "^4.0.1",
"socket.io": "^4.4.1",
"socket.io-client": "^4.4.1",
}
Example of implementation
import { createAdapter } from '@socket.io/redis-adapter';
import * as redis from 'redis';
import * as SocketIO from 'socket.io';
// ...
const socketServer = new SocketIO.Server( ... );
const pubClient = redis.createClient({
url: `redis://localhost:6379`,
legacyMode: true,
});
const subClient = pubClient.duplicate();
await pubClient.connect();
await subClient.connect();
socketServer.adapter(createAdapter(pubClient, subClient));
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
The "chunk" argument must be of type string or an instance of ...
In case this may help someone, I was using data type other than String , Number to be exact, so I changed it...
Read more >TypeError [ERR_INVALID_ARG_TYPE] - appsloveworld
Coding example for the question TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array ...
Read more >The "chunk" argument must be one of type string or Buffer ...
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be one of type string or Buffer. Received type object.
Read more >Redis-specific parameters - Amazon ElastiCache for Redis
If you do not specify a parameter group for your Redis cluster, then a default ... If you need to use one of...
Read more >Understanding the Top 5 Redis Performance Metrics - Datadog
Using critical Redis metrics to troubleshoot performance issues ... 4. Redis stores more than just strings . ... only string data types as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
yes, with
legacyMode: false
it works!@cesco69 that’s an interesting idea! Would you have time to open a pull request?