[SERVER-36182] db.js trying to reassign const Created: 18/Jul/18 Updated: 19/Jul/18 Resolved: 19/Jul/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 4.0.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ben Mullard | Assignee: | Nick Brewer |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
I'm using mongo shell 4.0.0 against MongoDB 2.4.9 to run an aggregation pipeline but it fails with this error:
I had a look at the source code and it looks like res is being declared as a constant on line 242
but is being reassigned on line 250. The problem may be that the version of MongoDB I'm using is way older than the client but, in my limited knowledge of Javascript, a const cannot be reassigned I can reproduce the error with this example query:
|
| Comments |
| Comment by Ben Mullard [ 19/Jul/18 ] |
|
Hi Nick, Thanks for your response. I don't have an earlier shell client but I did get my query working by using a script with pymongo 2.9. Unfortunately I can't upgrade mongod just yet as it's part of a legacy system. My real question, though, was the JavaScript didn't look correct where it's trying to reassign a constant. I don't know what scenarios can lead to entering that if block but it seems that anything that does will hit the same error. If nothing ever enters the if block wouldn't it be good to get rid of it altogether? Ben |
| Comment by Nick Brewer [ 19/Jul/18 ] |
|
benmullard MongoDB 2.4 is no longer supported, and you're probably correct that issues will arise when using a shell version that's so much newer than the server it's connecting to. That said, I did give this a try with an old version out of curiosity (2.6 to be exact) and I wasn't able to reproduce the issue using the example query you provided. I'd suggest trying an older shell (3.2.20 being our oldest supported version) to see if that resolves the issue; of course, I would also suggest upgrading to a supported version of mongod. -Nick |