Skip to content

Commit 2f20541

Browse files
committed
Fixed issue with dedicated channels strategy
The dedicated channels strategy would throw in `extractIdsFromSelector` when the selector did not match certain criteria. The code now checks these before selecting the strategy.
1 parent 58ba426 commit 2f20541

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/processors/getStrategy.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
import { Strategy } from '../constants';
22

3+
function canUseDedicatedChannels(selector) {
4+
if (!selector || !selector._id) {
5+
return false;
6+
}
7+
8+
if (typeof selector._id === 'string') {
9+
return true;
10+
}
11+
12+
if (typeof selector._id === 'object' && '$in' in selector._id) {
13+
return true;
14+
}
15+
16+
return false;
17+
}
18+
319
/**
420
* @param selector
521
* @param options
@@ -15,7 +31,7 @@ export default function getStrategy(selector = {}, options = {}) {
1531
return Strategy.LIMIT_SORT;
1632
}
1733

18-
if (selector && selector._id) {
34+
if (canUseDedicatedChannels(selector)) {
1935
return Strategy.DEDICATED_CHANNELS;
2036
}
2137

0 commit comments

Comments
 (0)