Commit a1e822c
Time out tree-sitter CDN fetches to fix offline hang
Closes #51
When the network is fully offline, the <script src=cdn.jsdelivr.net>
tag for web-tree-sitter fails fast and TreeSitter is undefined, so
initTreeSitter() returns null immediately and analysis falls back to
the regex tokenizer. But on partially offline / flaky networks the
runtime script can load from cache while subsequent wasm fetches hang
indefinitely. TreeSitter.init() and Language.load() had no timeout,
so analysis stalled forever on "Loading language parsers...".
Wrap both calls in a Promise.race against an 8s timeout. A timeout
rejects into the existing catch block, which returns null and lets
the regex parser take over.1 parent 3ad51ba commit a1e822c
1 file changed
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
791 | 791 | | |
792 | 792 | | |
793 | 793 | | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
794 | 801 | | |
795 | 802 | | |
796 | 803 | | |
797 | 804 | | |
798 | 805 | | |
799 | | - | |
| 806 | + | |
800 | 807 | | |
801 | 808 | | |
802 | 809 | | |
803 | | - | |
| 810 | + | |
804 | 811 | | |
805 | 812 | | |
806 | 813 | | |
| |||
826 | 833 | | |
827 | 834 | | |
828 | 835 | | |
829 | | - | |
| 836 | + | |
830 | 837 | | |
831 | 838 | | |
832 | 839 | | |
| |||
0 commit comments