[SERVER-14029] Suppress javascript callstacks from interactive shell Created: 22/May/14  Updated: 26/Oct/21  Resolved: 26/Oct/21

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: features we're not sure of

Type: Improvement Priority: Major - P3
Reporter: Eric Milkie Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2020-12-03 at 11.31.32 AM.png    
Participants:

 Description   

In 2.7 we added more descriptive callstacks when javascript exceptions propagate up to the top javascript level. This helped with debugging javascript scripts run by the shell, such as jstests run by the testing framework.

Unfortunately, interactive shell use also now generates these backtraces, even though they are of little use to interactive users. We should specifically suppress these callstacks in the shell's read-eval-print-loop.



 Comments   
Comment by Katya Kamenieva [ 03/Dec/20 ]

A user brought up that they get error message twice when using insertOne() or insertMany()

> db.grads_temp.insertOne({age:30, name: "Jina", major: "Math"})
WriteError({
  "index": 0,
  "code": 11000,
  "errmsg": "E11000 duplicate key error collection: test.grads_temp index: name_1 dup key: { name: \"Jina\" }",
  "op": {
    "_id": ObjectId("5fc914698d565772d4400943"),
    "age": 30,
    "name": "Jina",
    "major": "Math"
  }
}) :
WriteError({
  "index": 0,
  "code": 11000,
  "errmsg": "E11000 duplicate key error collection: test.grads_temp index: name_1 dup key: { name: \"Jina\" }",
  "op": {
    "_id": ObjectId("5fc914698d565772d4400943"),
    "age": 30,
    "name": "Jina",
    "major": "Math"
  }
})
WriteError@src/mongo/shell/bulk_api.js:465:48
mergeBatchResults@src/mongo/shell/bulk_api.js:871:49
executeBatch@src/mongo/shell/bulk_api.js:940:13
Bulk/this.execute@src/mongo/shell/bulk_api.js:1184:21
DBCollection.prototype.insertOne@src/mongo/shell/crud_api.js:264:9
@(shell):1:1

Comment by Eric Milkie [ 23/May/16 ]

It also doesn't help that the shell mixes printing with calls to log(); I think it would be desirable not to call log() in the shell at all, and also clean up message output so that everything goes to stderr and stdout is clean.

Comment by Eric Milkie [ 23/May/16 ]

It certainly made all of our shell helpers that throw js exceptions on error a lot harder to read. For example, here is what you see when you screw up using the "count" helper:

> db.foo.count()
2016-05-23T15:29:52.327-0400 E QUERY    [thread1] Error: count failed: { "ok" : 0, "errmsg" : "not master and slaveOk=false", "code" : 13435 } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBQuery.prototype.count@src/mongo/shell/query.js:387:11
DBCollection.prototype.count@src/mongo/shell/collection.js:1748:12
@(shell):1:1

Which is a lot more verbose than in previous versions and doesn't help contribute to a polished look for the product, especially for beginning users. Perhaps we should go through and remove all the throwing from our built-in js helpers? That would also achieve the same goal. I do agree that it's useful to see the callstack interactively, sometimes.

Comment by Mira Carey [ 23/May/16 ]

milkie,

Do you still think the more descriptive callstacks are too verbose? I'm thinking of a use case where a user is loading a number of their own complex libraries and making calls. More info doesn't seem bad.

Generated at Thu Feb 08 03:33:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.