Automattic / Automattic/kue

Adding new job with socket.io socket in data results with fail

Open
#771 1 comment 0 reactions 0 assignees View on GitHub
Question
Dominant language
JavaScript
Stars
9.4k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

Adding new job with socket.io socket in data results with fail with empty error object.

NOT-WORKING:

```
io.on('connection',function(socket){
queue
.create('getPostData',{socket:socket,data:data})
.attempts(3)
.priority('critical')
.save(function(err){
if(err){
return io.emit('getPostData',{result:false, message:'Cannot add task to queue',err:err});
}
});
}
```

WORKING:

```
io.on('connection',function(socket){
queue
.create('getPostData',{socketId:socket.id,data:data})
.attempts(3)
.priority('critical')
.save(function(err){
if(err){
return io.emit('getPostData',{result:false, message:'Cannot add task to queue',err:err});
}
});
}
```

And then restoring socket object by it's id.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue provides only connection-handler reproduction snippets, with no source file or test named. Start by tracing queue.create and how job data is serialized, then compare passing the socket object with passing socket.id; done means the reported failure is handled or clearly rejected and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.