Sublime Forum

Lock up and 100% CPU usage with TypeScript syntax

#1

I’m writing some TypeScript that looks like this:

const ExampleComponent = ({
  fetcher,
}: {
  fetcher?: () => Promise<Response> | void;
}) => {
  // Function body goes here
}

However, as soon as I type the bracket for <Response Sublime locks up. I discovered this because one of the test files in my project has this syntax, and as soon as Sublime saw this file I had problems using it. It didn’t always lock up, sometimes it just shows an empty file with a line in the center of the window.

Here’s what I was typing to trigger this:

I’ve reproduced this on a fresh install of Sublime Text 4 (Build 4107) with all the files deleted from ~/Library.

0 Likes

#2

Does it also reproduce in safe mode?

0 Likes

#3

It works OK in safe mode

0 Likes

#4

I tried it on another Mac with Sublime Text 4 installed, and I pasted it in as plain text and everything was fine. As soon as I switched the language to JavaScript/TypeScript it locked up

0 Likes

#5

Are you using some third party TS syntax or the one that comes pre built with ST ?

0 Likes

#6

The built in TypeScript, I do get the same issue with no plugins installed after a fresh install, and I’ve reproduced it on two Macs (one Intel, one m1)

0 Likes

#7

There is no “UnitTest (TypeScript React)” default syntax.

1 Like

#8

Oh it seems to come from A File Icon https://github.com/SublimeText/AFileIcon/blob/7385c476e5c74d3701e06241f260468ff67d6d49/icons/icons.json#L2320-L2332

0 Likes

#9

If I start in safe mode, switch language to JavaScript/TypeScript, then paste in my code from above, it still locks up, so I’m not sure if that plugin is the culprit (unless it is in an obscure way I don’t understand)

0 Likes

#10

Here I created a new account on the Mac, opened Sublime Text, switched to JavaScript/TypeScript, then pasted my code from the opening post:

0 Likes

#11

I can actually reproduce this on Ubuntu 16 as well with build 4110. Seems to be entering an infinite parse loop.

1 Like

#12

thank you! I’m relieved it’s not just me :smile:

1 Like

#13

This is the second time I see this (after https://github.com/JuliaEditorSupport/Julia-sublime/issues/101), looks like it has something to do with branching in syntax definitions. Might be a core bug and be worth to report on the issue tracker?

0 Likes

#14

I’ve got a fix for this in the works.

5 Likes

#15

thank you, I appreciate it!

0 Likes