From the linked BF, getting this error:
[js_test:jumbo1] 2017-06-21T19:33:50.646+0000 2017-06-21T19:33:50.628+0000 E QUERY [thread1] Error: command failed: { [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 "code" : 8, [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 "ok" : 0, [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 "errmsg" : "ensureIndex failed to create index on primary shard: operation was interrupted", [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 "$logicalTime" : { [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 "clusterTime" : Timestamp(1498073630, 21), [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 "signature" : { [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 "hash" : BinData(0,"VsxnCqW3qBtWUvl2gB08eikOs5k="), [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 "keyId" : NumberLong("6434177213490266132") [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 } [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 }, [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 "operationTime" : Timestamp(1498073630, 21) [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 } : undefined : [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 _getErrorWithCode@src/mongo/shell/utils.js:25:13 [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 doassert@src/mongo/shell/assert.js:16:14 [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 assert.commandWorked@src/mongo/shell/assert.js:403:5 [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 @jstests/sharding/jumbo1.js:8:1 [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 @jstests/sharding/jumbo1.js:1:2 [js_test:jumbo1] 2017-06-21T19:33:50.646+0000 failed to load: jstests/sharding/jumbo1.js
The command is failing here: https://github.com/mongodb/mongo/blob/7f0caad1b2e62bd8a1533f865fab220c8e853464/src/mongo/db/s/config/configsvr_shard_collection_command.cpp#L511-L516
An appropriate error code should be appended to the result returned to the mongos so that it can act appropriately. In general, shardCollection probably needs to append errors when it returns early.
This is needed so that our testing doesn't fail, because our JS tests always assert that shardCollection works and the stepdown suite can interrupt shardCollection at any point – so all the tests run in the stepdown suite are liable to fail non-deterministically.