{"action":"opened","issue":{"url":"https://api.github.com/repos/ReactiveX/rxjs/issues/2028","repository_url":"https://api.github.com/repos/ReactiveX/rxjs","labels_url":"https://api.github.com/repos/ReactiveX/rxjs/issues/2028/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/rxjs/issues/2028/comments","events_url":"https://api.github.com/repos/ReactiveX/rxjs/issues/2028/events","html_url":"https://github.com/ReactiveX/rxjs/issues/2028","id":182638230,"number":2028,"title":"mergeMap drops grouped observables greater than concurrency limit","user":{"login":"jeffbski","id":5689,"avatar_url":"https://avatars.githubusercontent.com/u/5689?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffbski","html_url":"https://github.com/jeffbski","followers_url":"https://api.github.com/users/jeffbski/followers","following_url":"https://api.github.com/users/jeffbski/following{/other_user}","gists_url":"https://api.github.com/users/jeffbski/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffbski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffbski/subscriptions","organizations_url":"https://api.github.com/users/jeffbski/orgs","repos_url":"https://api.github.com/users/jeffbski/repos","events_url":"https://api.github.com/users/jeffbski/events{/privacy}","received_events_url":"https://api.github.com/users/jeffbski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-12T21:25:24Z","updated_at":"2016-10-12T21:25:24Z","closed_at":null,"body":"It appears that mergeMap will drop grouped observables (from groupBy) greater than the concurrency limit. The extra groups are simply lost and never processed rather than simply being delayed.\r\n\r\n**RxJS version:** rxjs@5.0.0-rc.1\r\n\r\n**Code to reproduce:**\r\n```js\r\nconst CONCURRENCY = 1; // setting this to less than 3 will result in groups being lost\r\n\r\nRx.Observable.from([\r\n  { a: 1, b: 10 },\r\n  { a: 1, b: 20 },\r\n  { a: 2, b: 30 },\r\n  { a: 1, b: 40 },\r\n  { a: 1, b: 50 },\r\n  { a: 2, b: 60 },\r\n  { a: 3, b: 70 }\r\n])\r\n  .groupBy(x => x.a)\r\n  .mergeMap( /* call foo once per group with group.key */\r\n             group => {\r\n               return foo(group.key)\r\n                 .mergeMap(\r\n                   fx => group,\r\n                   (fx, obj) => ({ fx, obj })\r\n                 );\r\n             },\r\n             CONCURRENCY\r\n  )\r\n  .subscribe(x => console.log(x));\r\n\r\nfunction foo(a) {\r\n  if (a === 1) return Rx.Observable.of('ONE');\r\n  return Rx.Observable.of(a * 1000);\r\n}\r\n\r\n// Also can be duplicated in this more simple example below\r\nconsole.log('single mergeMap');\r\n\r\nRx.Observable.from([\r\n  { a: 1, b: 10 },\r\n  { a: 1, b: 20 },\r\n  { a: 2, b: 30 },\r\n  { a: 1, b: 40 },\r\n  { a: 1, b: 50 },\r\n  { a: 2, b: 60 },\r\n  { a: 3, b: 70 }\r\n])\r\n  .groupBy(x => x.a)\r\n  .mergeMap(group => group, CONCURRENCY)\r\n  .subscribe(x => console.log(x));\r\n```\r\n\r\n\r\n**Expected behavior:**\r\n```\r\n{ fx: 'ONE', obj: { a: 1, b: 10 } }\r\n{ fx: 'ONE', obj: { a: 1, b: 20 } }\r\n{ fx: 2000, obj: { a: 2, b: 30 } }\r\n{ fx: 'ONE', obj: { a: 1, b: 40 } }\r\n{ fx: 'ONE', obj: { a: 1, b: 50 } }\r\n{ fx: 2000, obj: { a: 2, b: 60 } }\r\n{ fx: 3000, obj: { a: 3, b: 70 } }\r\nsingle mergeMap\r\n{ a: 1, b: 10 }\r\n{ a: 1, b: 20 }\r\n{ a: 2, b: 30 }\r\n{ a: 1, b: 40 }\r\n{ a: 1, b: 50 }\r\n{ a: 2, b: 60 }\r\n{ a: 3, b: 70 }\r\n```\r\n\r\n**Actual behavior:**\r\n```\r\n{ fx: 'ONE', obj: { a: 1, b: 10 } }\r\n{ fx: 'ONE', obj: { a: 1, b: 20 } }\r\n{ fx: 'ONE', obj: { a: 1, b: 40 } }\r\n{ fx: 'ONE', obj: { a: 1, b: 50 } }\r\nsingle mergeMap\r\n{ a: 1, b: 10 }\r\n{ a: 1, b: 20 }\r\n{ a: 1, b: 40 }\r\n{ a: 1, b: 50 }\r\n```\r\n\r\n**Additional information:**\r\nThis appears to be a bug, since even though we are restricting the concurrency of mergeMap, I would have expected all of the groups to eventually be processed but the current code seems to drop the extra groups.\r\n"}}
{"actor":{"display_login":"jeffbski"}}