Update/Search Callback Issue
- Dominant language
- JavaScript
- Stars
- 9.4k
- Forks
- 858
- PR merge metrics
- No merged PRs in 30d
Description
When saving a new job you are not immediately able to search for it (using search keys) due to the fact that the indexing occurs after the update() functions callback (fn) is invoked. Given the code below the callback is often invoked before the search indexing has completed.
The search indexing should be run before the fn callback is invoked. I am sure it's faster this way though if you have the search enabled I assume you won't mind the penalty of indexing (vs getting incorrect results).
https://github.com/Automattic/kue/blob/master/lib/queue/job.js#L852
```
this.set('data', json, function() {
// state
this.state(this._state, fn); // I believe this is where the final callback is invoked.
}.bind(this));
// The index logic is happening here though it is a race condition with the above
// code for which will return first. In my experience the code above usually returns first.
if( !exports.disableSearch ) {
if( this.searchKeys() ) {
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in lib/queue/job.js around line 852 and trace the update callback alongside the search-indexing branch. Reproduce saving a job followed immediately by a search, then verify that the callback is not invoked until indexing has completed and the job is searchable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100