JS Code Hints Crash Preventer

1. Update Tern
2. Implement timeout

cc @dangoor 

Most of the changes in this file are due to indenting code to put it in a `try` block, so use `?w=1` for a much simplified diff.