Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving a file is hanging indefinitely #88

Open
lildesert opened this issue Nov 22, 2023 · 5 comments
Open

Saving a file is hanging indefinitely #88

lildesert opened this issue Nov 22, 2023 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@lildesert
Copy link

Describe the bug
Hi, since today this extension has been causing the save file action to hang indefinitely.
I deactivated all my VSCode extensions and this one seems to cause the issue. I don't have any more insight but I'll be happy to send more if someone provides guidance.

I use the v0.5.2 and also tried the v0.5.1 which causes the same issue.

Here's my VSCode info:

Version: 1.84.2
Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
Date: 2023-11-09T10:52:57.054Z (1 wk ago)
Electron: 25.9.2
ElectronBuildId: 24603566
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 21.5.0

Expected behavior
Saving a file should be instant.

Screenshots
image

@lildesert lildesert added the bug Something isn't working label Nov 22, 2023
@summaarum
Copy link

Having the same issue. Used the VS Code extension bisect tool and in fact it seems to be this extension.

Screenshot 2023-12-10 at 11 29 29

To me it seems to happen when working with code where the TS errors are super long. I've solved it for now with setting "noErrorTruncation": false,. It's not ideal but it seems to work.

@yoavbls yoavbls added the help wanted Extra attention is needed label Mar 1, 2024
@yoavbls
Copy link
Owner

yoavbls commented Mar 1, 2024

It is weird because the extension does not interfere saving of files,
Does someone see some behavior that could cause that? maybe something that we're not doing correctly in the extension?

I also failed to reproduce it, so it would be great if someone could help with that.

@kevinramharak
Copy link
Contributor

I attempted to reproduce by checking out the typescript and vuejs/core repositories. As both are pretty large and vuejs/core is a monorepo. I cannot reproduce any problems with the extensions. Running the extension host profile does not show any performance issues with the extension.

So far it seems this issue and #102 seem to use a macbook, I use a windows machine. Doubt its related but if more people raise issues it could be worth asking.

To me it seems to happen when working with code where the TS errors are super long. I've solved it for now with setting "noErrorTruncation": false,. It's not ideal but it seems to work.

This seems interesting to me. Maybe it has to do with truncated errors? Something like a recursion with regular expressions? It all seems to be handled here:

const convertToValidType = (type: string) =>
`type x = ${type
// Add missing parentheses when the type ends with "...""
.replace(/(.*)\.\.\.$/, (_, p1) => addMissingParentheses(p1))
// Replace single parameter function destructuring because it's not a valid type
// .replaceAll(/\((\{.*\})\:/g, (_, p1) => `(param: /* ${p1} */`)
// Change `(...): return` which is invalid to `(...) => return`
.replace(/^(\(.*\)): /, (_, p1) => `${p1} =>`)
.replaceAll(/... (\d{0,}) more .../g, (_, p1) => `___${p1}MORE___`)
.replaceAll(/... (\d{0,}) more ...;/g, (_, p1) => `___MORE___: ${p1};`)
.replaceAll("...;", "___KEY___: ___THREE_DOTS___;")
.replaceAll("...", "__THREE_DOTS__")};`;
const convertToOriginalType = (type: string) =>
type
.replaceAll("___KEY___: ___THREE_DOTS___", "...;")
.replaceAll("__THREE_DOTS__", "...")
.replaceAll(/___MORE___: (\d{0,});/g, (_, p1) => `... ${p1} more ...;`)
.replaceAll(/___(\d{0,})MORE___/g, (_, p1) => `... ${p1} more ...`)
.replaceAll(/... (\d{0,}) more .../g, (_, p1) => `/* ${p1} more */`) // ... x more ... not shown sell
// .replaceAll(/\(param\: \/\* (\{ .* \}) \*\//g, (_, p1) => `(${p1}: `)
.replace(/type x =[ ]?((.|\n)*);.*/g, "$1")
.trim();

I don't see any reason for the extension to stall in a seemingly infinite loop.

@ChristopherHaws
Copy link

Just an FYI, I run Windows, Linux, and macOS and it happens on all three for me, so it doesn't seem to be platform specific. I see this issue most often when moving a typescript file which triggers vscode to update the import paths in any file referencing the moved file.

@kevinramharak
Copy link
Contributor

kevinramharak commented May 7, 2024

@ChristopherHaws Thanks for the addition, that is helpful. I'm gonna see if I can reproduce it by moving a file causing TS to update the imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants