Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Svelte LSP crashes due to out of memory #2738

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

Closed
MrWaip opened this issue Apr 14, 2025 · 44 comments
Closed

Svelte LSP crashes due to out of memory #2738

MrWaip opened this issue Apr 14, 2025 · 44 comments
Labels
awaiting submitter bug Something isn't working

Comments

@MrWaip
Copy link

MrWaip commented Apr 14, 2025

Describe the bug

Hi!

At my work in our monolithic project the svelte extension started to crash on startup. This doesn't happen on version 108.5.2, so we locked it. In fact, VS Code turns into a primitive text editor.

I just checked, the problem is reproduced on version 109.5.4.
The project uses Svelte 4.2.18

Debugger listening on ws://127.0.0.1:9229/cb55dc39-8085-4658-803d-d836a3c4b77a
For help, see: https://nodejs.org/en/docs/inspector
Initialize language server at  file:///Users/mrwaip/code/project
Initialize new ts service at  /Users/mrwaip/code/project/tsconfig.json
Trying to load configs for /Users/mrwaip/code/project
Loaded config at  /Users/mrwaip/code/project/svelte.config.js
SnapshotManager File Statistics:
Project files: 13363
Svelte files: 3729
From node_modules: 0
Total: 13363
SnapshotManager File Statistics:
Project files: 13363
Svelte files: 3729
From node_modules: 2938
Total: 16608

<--- Last few GCs --->

[64316:0x108002e0000]    91020 ms: Mark-Compact 4065.1 (4074.8) -> 4063.5 (4074.8) MB, pooled: 2 MB, 617.17 / 0.00 ms  (average mu = 0.129, current mu = 0.051) allocation failure; scavenge might not succeed
[64316:0x108002e0000]    91884 ms: Mark-Compact 4065.5 (4074.8) -> 4063.7 (4075.1) MB, pooled: 2 MB, 857.50 / 0.00 ms  (average mu = 0.061, current mu = 0.007) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0x11503c0bc node::OnFatalError(char const*, char const*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 2: 0x10f496af4 node::GetEnvironmentIsolateData(node::Environment*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 3: 0x10f496a88 node::GetEnvironmentIsolateData(node::Environment*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 4: 0x10f66f9b0 fontations_ffi$cxxbridge1$has_any_color_table [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 5: 0x10f685534 v8::internal::StrongRootAllocatorBase::deallocate_impl(unsigned long*, unsigned long) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 6: 0x10f684fac v8::internal::StrongRootAllocatorBase::deallocate_impl(unsigned long*, unsigned long) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 7: 0x10febc018 cppgc::internal::AgeTable::ResetForTesting() [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 8: 0x10f66d2e4 fontations_ffi$cxxbridge1$has_any_color_table [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 9: 0x10f663260 fontations_ffi$cxxbridge1$has_any_color_table [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
10: 0x10f6420e8 fontations_ffi$cxxbridge1$has_any_color_table [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
11: 0x10e230c30 uv_get_osfhandle [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
12: 0x10fb48050 v8::internal::TickSample::print() const [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
13: 0x10fb00d30 v8::internal::TickSample::print() const [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
14: 0x177eafa74 
15: 0x177f37c1c 
16: 0x177e9bc84 
17: 0x170f3392c 
18: 0x170cce70c 
19: 0x170deb4d8 
20: 0x170da5a40 
21: 0x170de18dc 
22: 0x170e34108 
23: 0x170eace68 
24: 0x170d40fa8 
25: 0x1709032d0 
26: 0x170d9dc18 
27: 0x177e0d624 
28: 0x177e0d624 
29: 0x177e0d624 
30: 0x177e0d624 
31: 0x177e0d624 
32: 0x177e0d624 
33: 0x177e0d624 
34: 0x177e4de28 
35: 0x177f26a18 
36: 0x177e3ca9c 
37: 0x177e0b0f4 
38: 0x10f5c65a0 v8::Unwinder::PCIsInV8(unsigned long, v8::MemoryRange const*, void*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
39: 0x10f5c7334 v8::Unwinder::PCIsInV8(unsigned long, v8::MemoryRange const*, void*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
40: 0x10f5c7488 v8::Unwinder::PCIsInV8(unsigned long, v8::MemoryRange const*, void*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
41: 0x10f5f4ff0 v8::Unwinder::PCIsInV8(unsigned long, v8::MemoryRange const*, void*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
42: 0x114f70a04 node::CallbackScope::~CallbackScope() [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
43: 0x114f706cc node::CallbackScope::~CallbackScope() [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
44: 0x115043f60 node::OnFatalError(char const*, char const*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
45: 0x1150573b8 fontations_ffi$cxxbridge1$BridgeOutlineCollection$operator$sizeof [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
46: 0x1150358fc node::Buffer::New(v8::Isolate*, char*, unsigned long) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
47: 0x10e27c83c uv_barrier_destroy [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
48: 0x10e27febc uv_async_send [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
49: 0x10e29098c uv_free_interface_addresses [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
50: 0x10e280388 uv_run [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
51: 0x114f716b8 node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
52: 0x114f72558 node::SpinEventLoop(node::Environment*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
53: 0x10e295084 v8::ValueSerializer::Delegate::HasCustomHostObject(v8::Isolate*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
54: 0x10e2911c8 ElectronInitializeICUandStartNode [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
55: 0x180274274 start [/usr/lib/dyld]
[Error - 09:14:45] Server process exited with signal SIGABRT.
[Info  - 09:14:45] Connection to server got closed. Server will restart.
true
Debugger listening on ws://127.0.0.1:9229/85e9ed6a-25c6-4232-85e5-2aa6dbca56ff
For help, see: https://nodejs.org/en/docs/inspector
Initialize language server at  file:///Users/mrwaip/code/project
Initialize new ts service at  /Users/mrwaip/code/project/tsconfig.json
Trying to load configs for /Users/mrwaip/code/project
Loaded config at  /Users/mrwaip/code/project/svelte.config.js
SnapshotManager File Statistics:
Project files: 13363
Svelte files: 3729
From node_modules: 0
Total: 13363

Reproduction

IDK. Big codebase.

Expected behaviour

LSP doesn't crash

System Info

  • OS: Mac OS
  • IDE: VS Code
  • Extension version: 109.5.4
  • RAM: 16GB
  • Svelte package version: 4.2.18
  • Svelte kit: 2.9.0

Which package is the issue about?

svelte-language-server

Additional Information, eg. Screenshots

Vs Code config:

{
	"typescript.tsserver.maxTsServerMemory": 8192,
	"svelte.language-server.runtime-args": ["--max-old-space-size=8192"]
}
@MrWaip MrWaip added the bug Something isn't working label Apr 14, 2025
@MrWaip
Copy link
Author

MrWaip commented Apr 14, 2025

By the way, after the server crashes, it restarts, reserves all possible memory and crashes again. The laptop is like a stove

@dummdidumm
Copy link
Member

dummdidumm commented Apr 14, 2025

SnapshotManager File Statistics:
Project files: 13363
Svelte files: 3729
From node_modules: 2938
Total: 16608

To clarify, is this the correct number? 13k project files, i.e. stuff in your src folder?

This doesn't happen on version 108.5.2

I assume you mean 109.5.2?

the problem is reproduced on version 109.5.4

To clarify, the crash already happens on version 109.5.3, i.e. 109.5.2 is the last one that works? 109.5.3 bumps TypeScript to version 5.8, wondering if that has something to do with it.

@MrWaip
Copy link
Author

MrWaip commented Apr 14, 2025

To clarify, is this the correct number? 13k project files, i.e. stuff in your src folder?

I assume that LSP is based on ./tsconfig.json. 13k files inside included dirs

// ./tsconfig.json
{
	"extends": "./.svelte-kit/tsconfig.json",
	"compilerOptions": {
		"moduleResolution": "bundler",
		"module": "es2022",
		"lib": ["es2021", "dom"],
		"target": "es2022",
	
	},
	"include": [
		"src/**/*.d.ts",
		"src/**/*.js",
		"src/**/*.ts",
		"src/**/*.svelte",
		"infra/**/*.ts",
		"tests/**/*.ts",
		".storybook/**/*.ts",
		"scripts/swagger/features.swagger.ts"
	],
	"exclude": ["src/**/*.stories.svelte"]
}
// .svelte-kit/tsconfig.json
{
"include": [
		"ambient.d.ts",
		"non-ambient.d.ts",
		"./types/**/$types.d.ts",
		"../vite.config.js",
		"../vite.config.ts",
		"../src/**/*.js",
		"../src/**/*.ts",
		"../src/**/*.svelte",
		"../tests/**/*.js",
		"../tests/**/*.ts",
		"../tests/**/*.svelte"
	],
	"exclude": [
		"../node_modules/**",
		"../src/service-worker.js",
		"../src/service-worker/**/*.js",
		"../src/service-worker.ts",
		"../src/service-worker/**/*.ts",
		"../src/service-worker.d.ts",
		"../src/service-worker/**/*.d.ts"
	]
}

@MrWaip
Copy link
Author

MrWaip commented Apr 14, 2025

I assume you mean 109.5.2?

No. There are no problems with version 108.5.2. We have not tested all versions, we found this one using empirical method.

@MrWaip
Copy link
Author

MrWaip commented Apr 14, 2025

To clarify, the crash already happens on version 109.5.3, i.e. 109.5.2 is the last one that works? 109.5.3 bumps TypeScript to version 5.8, wondering if that has something to do with it.

It is safe to say that after 108.5.2 there are versions on which the problem is reproduced. Definitely on the latest version (109.5.4) it is reproduced

@jasonlyu123
Copy link
Member

Is this the same project as #2329? I am really curious about what exactly this project is about when you can create 5000 more source files in a year. Are there a lot of generated files? #2725 is another recent out-of-memory report, but it seems like it is because the library-generated schema type is way too complicated. Have you used any similar library?

@dummdidumm
Copy link
Member

dummdidumm commented Apr 14, 2025

I assume you mean 109.5.2?

No. There are no problems with version 108.5.2. We have not tested all versions, we found this one using empirical method.

So you are actually refering to https://github.com/sveltejs/language-tools/releases/tag/extensions-108.5.2 which was realeased more than 6 months ago? Why did the error only occur now then? What has changed recently in your project to may have caused this?

@MrWaip
Copy link
Author

MrWaip commented Apr 14, 2025

Is this the same project as #2329?

Yes, it's the same project. The project has been alive and developing for 4 years now. A lot of code.

@MrWaip
Copy link
Author

MrWaip commented Apr 14, 2025

Why did the error only occur now then? What has changed recently in your project to may have caused this

I guess it's related to svelte 5 support. In my free time I will try other versions of the extension to find out exactly which one is causing the problem.

@MrWaip
Copy link
Author

MrWaip commented Apr 15, 2025

Hi, I checked the versions and found the one with which the problem starts

109.0 - ok
109.0 - ok
109.1 - ok
109.3 - ok
109.4 - ok
109.5 - ok
109.5.1 - ok

Starting inspector on 127.0.0.1:9229 failed: address already in use
Initialize language server at  file:///Users/mrwaip/code/project
Initialize new ts service at  /Users/mrwaip/code/project/tsconfig.json
Trying to load configs for /Users/mrwaip/code/project
Loaded config at  /Users/mrwaip/code/project/svelte.config.js
SnapshotManager File Statistics:
Project files: 13401
Svelte files: 3719
From node_modules: 0
Total: 13401

109.5.2 - ok

Debugger listening on ws://127.0.0.1:9229/979919f8-30c2-4a14-abac-17359a7b516a
For help, see: https://nodejs.org/en/docs/inspector
Initialize language server at  file:///Users/mrwaip/code/project
Initialize new ts service at  /Users/mrwaip/code/project/tsconfig.json
Trying to load configs for /Users/mrwaip/code/project
Loaded config at  /Users/mrwaip/code/project/svelte.config.js
SnapshotManager File Statistics:
Project files: 13401
Svelte files: 3719
From node_modules: 0
Total: 13401
[Error - 00:27:26] Request textDocument/codeLens failed.
  Message: Request textDocument/codeLens failed with message: Cannot read properties of undefined (reading 'filter')
  Code: -32603 

109.5.3 - fail

Debugger listening on ws://127.0.0.1:9229/6f09d27b-bfe9-4848-9281-ec75327ce49e
For help, see: https://nodejs.org/en/docs/inspector
Initialize language server at  file:///Users/mrwaip/code/project
Initialize new ts service at  /Users/mrwaip/code/project/tsconfig.json
Trying to load configs for /Users/mrwaip/code/project
Loaded config at  /Users/mrwaip/code/project/svelte.config.js
SnapshotManager File Statistics:
Project files: 13401
Svelte files: 3719
From node_modules: 0
Total: 13401
SnapshotManager File Statistics:
Project files: 13401
Svelte files: 3719
From node_modules: 2943
Total: 16652

109.5.4 - fail

Starting inspector on 127.0.0.1:9229 failed: address already in use
Initialize language server at  file:///Users/mrwaip/code/project
Initialize new ts service at  /Users/mrwaip/code/project/tsconfig.json
Trying to load configs for /Users/mrwaip/code/project
Loaded config at  /Users/mrwaip/code/project/svelte.config.js
SnapshotManager File Statistics:
Project files: 13401
Svelte files: 3719
From node_modules: 0
Total: 13401
SnapshotManager File Statistics:
Project files: 13401
Svelte files: 3719
From node_modules: 2923
Total: 16632
SnapshotManager File Statistics:
Project files: 13401
Svelte files: 3719
From node_modules: 2976
Total: 16696

```

@MrWaip
Copy link
Author

MrWaip commented Apr 15, 2025

A few notes:

  1. In 109.5.2 i got an error
Request textDocument/codeLens failed.
  Message: Request textDocument/codeLens failed with message: Cannot read properties of undefined (reading 'filter')
  Code: -32603 

  1. In 109.5.3 and after several scans occur after which the number of modules in the node_modules category increases

@dummdidumm
Copy link
Member

I assume that LSP is based on ./tsconfig.json. 13k files inside included dirs

To clarify: Do you really have 13k files in your src, infra and tests folders (according to your tsconfig)?

Also very strange that according to the logs you have 0 files included from node_modules.

109.5.3 fail

https://github.com/sveltejs/language-tools/releases/tag/extensions-109.5.3 is the list of changes. From a quick look only the TypeScript version bump stands out.

Could you test if that version bump is the culprit? In order to test it, go into the folder where your VS Code extension is installed, in there go into node_modules and replace the typescript package with TypeScript 5.7.

@MrWaip
Copy link
Author

MrWaip commented Apr 16, 2025

Here are the statistics for directories

infra/:        5 files
node_modules/:    91451 files
scripts/:       69 files
src/:    12916 files
tests/:     7071 files

@MrWaip
Copy link
Author

MrWaip commented Apr 16, 2025

I changed the package version to 5.7, it didn't help. I added the "MODDED" log to the extension

Proof:

> pwd

# output
/Users/mrwaip/.vscode/extensions/svelte.svelte-vscode-109.5.3

> cat ./node_modules/typescript/package.json | grep version

#  output    
"version": "5.7.3",
For help, see: https://nodejs.org/en/docs/inspector
MODDED!!!!!!!!!
Initialize language server at  file:///Users/mrwaip/code/project
Initialize new ts service at  /Users/mrwaip/code/project/tsconfig.json
Trying to load configs for /Users/mrwaip/code/project
Loaded config at  /Users/mrwaip/code/project/svelte.config.js
SnapshotManager File Statistics:
Project files: 13401
Svelte files: 3719
From node_modules: 0
Total: 13401
SnapshotManager File Statistics:
Project files: 13401
Svelte files: 3719
From node_modules: 2938
Total: 16647

<--- Last few GCs --->

[91496:0x11800310000]    94970 ms: Mark-Compact 4063.9 (4078.8) -> 4060.2 (4079.3) MB, pooled: 0 MB, 677.38 / 0.00 ms  (average mu = 0.066, current mu = 0.031) allocation failure; scavenge might not succeed
[91496:0x11800310000]    95667 ms: Mark-Compact 4064.3 (4079.3) -> 4060.7 (4079.8) MB, pooled: 0 MB, 683.67 / 0.00 ms  (average mu = 0.043, current mu = 0.019) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0x1143440bc node::OnFatalError(char const*, char const*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 2: 0x10e79eaf4 node::GetEnvironmentIsolateData(node::Environment*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 3: 0x10e79ea88 node::GetEnvironmentIsolateData(node::Environment*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 4: 0x10e9779b0 fontations_ffi$cxxbridge1$has_any_color_table [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 5: 0x10e98d534 v8::internal::StrongRootAllocatorBase::deallocate_impl(unsigned long*, unsigned long) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 6: 0x10e98cfac v8::internal::StrongRootAllocatorBase::deallocate_impl(unsigned long*, unsigned long) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 7: 0x10f1c4018 cppgc::internal::AgeTable::ResetForTesting() [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 8: 0x10e9752e4 fontations_ffi$cxxbridge1$has_any_color_table [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 9: 0x10e96b260 fontations_ffi$cxxbridge1$has_any_color_table [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
10: 0x10e94a0e8 fontations_ffi$cxxbridge1$has_any_color_table [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
11: 0x10d53c448 uv_get_osfhandle [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
12: 0x10ee139d8 v8::internal::TickSample::print() const [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
13: 0x177eafa74 
14: 0x177f37f1c 
15: 0x177e9bc84 
16: 0x1701470d4 
17: 0x170f2dca0 
18: 0x17016e54c 
19: 0x1704a3478 
20: 0x170f40fc0 
21: 0x170fb68fc 
22: 0x170170808 
23: 0x170fb16e8 
24: 0x170cc6ba8 
25: 0x1704438b0 
26: 0x170462138 
27: 0x177e0d624 
28: 0x177e0d624 
29: 0x177e0d624 
30: 0x177e0d624 
31: 0x177e0d624 
32: 0x177e0d624 
33: 0x177e0d624 
34: 0x177e4de28 
35: 0x177f26a18 
36: 0x177e3ca9c 
37: 0x177e0b0f4 
38: 0x10e8ce5a0 v8::Unwinder::PCIsInV8(unsigned long, v8::MemoryRange const*, void*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
39: 0x10e8cf334 v8::Unwinder::PCIsInV8(unsigned long, v8::MemoryRange const*, void*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
40: 0x10e8cf488 v8::Unwinder::PCIsInV8(unsigned long, v8::MemoryRange const*, void*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
41: 0x10e8fcff0 v8::Unwinder::PCIsInV8(unsigned long, v8::MemoryRange const*, void*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
42: 0x114278a04 node::CallbackScope::~CallbackScope() [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
43: 0x1142786cc node::CallbackScope::~CallbackScope() [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
44: 0x11434bf60 node::OnFatalError(char const*, char const*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
45: 0x11435f3b8 fontations_ffi$cxxbridge1$BridgeOutlineCollection$operator$sizeof [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
46: 0x11433d8fc node::Buffer::New(v8::Isolate*, char*, unsigned long) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
47: 0x10d58483c uv_barrier_destroy [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
48: 0x10d587ebc uv_async_send [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
49: 0x10d59898c uv_free_interface_addresses [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
50: 0x10d588388 uv_run [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
51: 0x1142796b8 node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
52: 0x11427a558 node::SpinEventLoop(node::Environment*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
53: 0x10d59d084 v8::ValueSerializer::Delegate::HasCustomHostObject(v8::Isolate*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
54: 0x10d5991c8 ElectronInitializeICUandStartNode [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
55: 0x19433eb4c start [/usr/lib/dyld]
[Error - 09:38:17] Server process exited with signal SIGABRT.
[Info  - 09:38:17] Connection to server got closed. Server will restart.
true
Debugger listening on ws://127.0.0.1:9229/040d6fb7-5de1-4f1b-81e3-77d3e230087e
For help, see: https://nodejs.org/en/docs/inspector
MODDED!!!!!!!!!
Initialize language server at  file:///Users/mrwaip/code/project
Initialize new ts service at  /Users/mrwaip/code/project/tsconfig.json
Trying to load configs for /Users/mrwaip/code/project
Loaded config at  /Users/mrwaip/code/project/svelte.config.js
SnapshotManager File Statistics:
Project files: 13401
Svelte files: 3719
From node_modules: 0
Total: 13401

@jasonlyu123
Copy link
Member

Can you try this to see if you can increase the memory limit above 4GB? #2725 (comment).

@dummdidumm
Copy link
Member

@jasonlyu123 any idea which change in https://github.com/sveltejs/language-tools/releases/tag/extensions-109.5.3 could've caused this? My guess would be #2635 or #2676 (for reasons unknown to me) because I can't see anything else affecting this.

@paoloricciuti
Copy link
Member

@jasonlyu123 any idea which change in https://github.com/sveltejs/language-tools/releases/tag/extensions-109.5.3 could've caused this? My guess would be #2635 or #2676 (for reasons unknown to me) because I can't see anything else affecting this.

Could it be #2668 since it needs to check the snippets over and over until they are stable?

@MrWaip
Copy link
Author

MrWaip commented Apr 16, 2025

Can you try this to see if you can increase the memory limit above 4GB? [#2725 (comment)]
(#2725 (comment)).

I don't know. Taking a snapshot took about 10 minutes and ate up all my RAM.

Image

@MrWaip
Copy link
Author

MrWaip commented Apr 16, 2025

Image

@MrWaip
Copy link
Author

MrWaip commented Apr 16, 2025

Image

Here is a snapshot after a couple of minutes

Sorry but I can't compare them because they weigh about 7GB each and just don't fit into the PC's memory

@jasonlyu123
Copy link
Member

Are these screenshots taken from 109.5.2 and 109.5.4, respectively, both with the svelte.language-server.runtime config? If so, does that mean it no longer crashes if the memory limit is increased to 8GB? That would also mean that it isn't an infinite/large loop problem like Paolo is suspecting.

From this Electron documentation, the reason for the 4GB limit is pointer compression, which also reduces the memory by up to 40%. If you were using 6.2GB of memory without pointer compression, then in the best case, it is 3.7GB with pointer compression. It's already very close to the 4GB limit. Maybe that meant the problem is just somehow the memory usage is increased a bit from 109.5.2 to 109.5.3?

@MrWaip
Copy link
Author

MrWaip commented Apr 17, 2025

Nope. Both screenshots from 109.5.3

@jasonlyu123
Copy link
Member

Oh. I misunderstood what you meant. Can you take the same screenshot of 109.5.2 with the svelte.language-server.runtime config? I tried with my own project and saw pretty much the same memory between 109.5.2 and 109.5.3. Looking at the diff between these versions, there also doesn't seem to be changes that might increase memory usage or cause memory leaks.

@MrWaip
Copy link
Author

MrWaip commented Apr 17, 2025

Sorry. I don't quite understand what needs to be done to help you. Do you want me to compare snapshots from 100.5.2 and 109.5.3?

@MrWaip
Copy link
Author

MrWaip commented Apr 17, 2025

Also yes, I redefined runntime path in config to locally installed nosejs version 22, but lsp still crashes

@jasonlyu123
Copy link
Member

Also yes, I redefined runntime path in config to locally installed nosejs version 22, but lsp still crashes

Weird, if it still crashes, how do you record the heap snapshot? What I want to know is if increasing the memory limit stops the crash. If it does stop the crash, I want to know the difference in memory usage between 109.5.2 and 109.5.3. The difference between the total heap usage and the kinds of objects that take up most memory. I don't need the comparison using the diff tool in Chrome Dev Tools.

@MrWaip
Copy link
Author

MrWaip commented Apr 17, 2025

Inside debugger I stop the code. Also I assume while snapshotting code is freezed

@MrWaip
Copy link
Author

MrWaip commented Apr 17, 2025

I want to know the difference in memory usage between 109.5.2 and 109.5.3

I'll try, but later

@MrWaip
Copy link
Author

MrWaip commented Apr 17, 2025

Image

In version 109.5.2 after full initialization (for example goto works in svelte files) taking a snapshot took much less time

@jasonlyu123
Copy link
Member

Inside debugger I stop the code. Also I assume while snapshotting code is freezer

Did you set a breakpoint? If so, where is the breakpoint? Or the language server is stuck in loading, and you just stop it without knowing where it actually stops? If it is the latter, it does sound like there might be an infinite loop.

@MrWaip
Copy link
Author

MrWaip commented Apr 17, 2025

Image

Compared the versions 109.5.2 and 109.5.3. Here is the result

Snapshot 1 - 109.5.2
heap end - 109.5.3 after few minutes of run

@MrWaip
Copy link
Author

MrWaip commented Apr 17, 2025

Did you set a breakpoint? If so, where is the breakpoint

I waited a few minutes before it overflow and pause process

Image

@jasonlyu123
Copy link
Member

jasonlyu123 commented Apr 17, 2025

Oh. If it is paused, did the debugger show where it stopped?

Sorry for the long conversation, I kind of have remote debugging since I can't reproduce the issue. If you're in the Svelte Discord, you could open a thread in the https://discord.com/channels/457912077277855764/689494103380983930. Messaging in a discord thread might be better than constantly pinging other people on this issue.

@MrWaip
Copy link
Author

MrWaip commented Apr 17, 2025

I can't reproduce the issue

I think it's high time you started some kind of benchmark project for such things)

@MrWaip
Copy link
Author

MrWaip commented Apr 19, 2025

did the debugger show where it stopped

Sorry for the long reply, execution stopped somewhere inside Nodejs while processing tasks

@MrWaip
Copy link
Author

MrWaip commented Apr 19, 2025

Image

I waited until more memory was allocated and paused the process in the debugger.

I tried jumping around the breakpoints, and was always inside the file parsing.

I conclude that something makes Typescript scan the project endlessly. This is confirmed even by snapshots, because the sources in memory grow the most

Maybe here :
extensions-109.5.2...extensions-109.5.3#diff-97a7df4dae3b3bf59d913c63419e7d3bd51f25d8f428eee31c0410594ee83a61


scan (typescript.js:12774)
nextTokenWithoutCheck (typescript.js:33536)
nextToken (typescript.js:33546)
parseExpectedMatchingBrackets (typescript.js:33729)
parseBlock (typescript.js:37104)
parseStatement (typescript.js:37555)
parseListElement (typescript.js:34235)
parseList (typescript.js:34220)
parseBlock (typescript.js:37103)
parseStatement (typescript.js:37555)
parseListElement (typescript.js:34235)
parseList (typescript.js:34220)
parseBlock (typescript.js:37103)
parseStatement (typescript.js:37555)
parseListElement (typescript.js:34235)
parseList (typescript.js:34220)
parseBlock (typescript.js:37103)
parseFunctionBlock (typescript.js:37134)
parseArrowFunctionExpressionBody (typescript.js:36106)
parseParenthesizedArrowFunctionExpression (typescript.js:36095)
tryParseParenthesizedArrowFunctionExpression (typescript.js:35908)
parseAssignmentExpressionOrHigher (typescript.js:35810)
parseExpression (typescript.js:35781)
doOutsideOfContext (typescript.js:33436)
allowInAnd (typescript.js:33457)
parseExpressionOrLabeledStatement (typescript.js:37353)
parseStatement (typescript.js:37663)
parseListElement (typescript.js:34235)
parseList (typescript.js:34220)
parseBlock (typescript.js:37103)
parseFunctionBlock (typescript.js:37134)
parseFunctionBlockOrSemicolon (typescript.js:37769)
parseFunctionDeclaration (typescript.js:37917)
parseStatement (typescript.js:37597)
parseListElement (typescript.js:34235)
parseList (typescript.js:34220)
parseSourceFileWorker (typescript.js:33250)
parseSourceFile (typescript.js:33077)
createSourceFile (typescript.js:32912)
createLanguageServiceSourceFile (typescript.js:151634)
acquireOrUpdateDocument (typescript.js:143049)
acquireDocumentWithKey (typescript.js:142972)
registry.acquireDocumentWithKey (service.ts:1398)
getOrCreateSourceFileByPath (typescript.js:151985)
getOrCreateSourceFile (typescript.js:151964)
(anonymous) (typescript.js:151885)
getSourceFileWithCache (typescript.js:125293)
findSourceFileWorker (typescript.js:127649)
findSourceFile (typescript.js:127565)
processImportedModules (typescript.js:127975)
findSourceFileWorker (typescript.js:127714)
findSourceFile (typescript.js:127565)
processImportedModules (typescript.js:127975)
findSourceFileWorker (typescript.js:127714)
findSourceFile (typescript.js:127565)
processImportedModules (typescript.js:127975)
findSourceFileWorker (typescript.js:127714)
findSourceFile (typescript.js:127565)
(anonymous) (typescript.js:127514)
getSourceFileFromReferenceWorker (typescript.js:127485)
processSourceFile (typescript.js:127512)
processRootFile (typescript.js:127343)
(anonymous) (typescript.js:126084)
forEach (typescript.js:2305)
createProgram (typescript.js:126084)
synchronizeHostDataWorker (typescript.js:151916)
synchronizeHostData (typescript.js:151811)
getProgram (typescript.js:151993)
updateIfDirty (service.ts:980)
getService (service.ts:516)
getLSAndTSDoc (LSAndTSDocResolver.ts:171)

@MrWaip
Copy link
Author

MrWaip commented Apr 28, 2025

@dummdidumm hi, any great ideas? Need more debug?

@jasonlyu123
Copy link
Member

jasonlyu123 commented Apr 29, 2025

Update from my side, another user in the Svelte Discord is experiencing a similar issue with a project far smaller, so the project size is likely not the problem. Judging from the CPU profile they provided and what you find, the problem seems to be that something keeps triggering file updates, so the typescript kept having to rebuild the program. Or some cache is not being used correctly, so it has to start over again. But I still can't figure out what caused the problem.

At this point, I don't think there is much I can do unless there is a reproduction. Their project is far smaller, so maybe it's more possible for them to narrow down the problem for a reproduction.

@gwilson152
Copy link

I am not sure if I can be of much help, as I am not terribly experienced with Svelte, however, I have a small project I started on Friday. Even having resolved all typing errors/etc, I am running into this. I have a much larger project configured nearly identical which doesn't have the issues but is operating with the node adapter. I am not terribly concerned about resolving it for myself, but if the project would be helpful for inspection, I can mark the repo public.

@paoloricciuti
Copy link
Member

I am not sure if I can be of much help, as I am not terribly experienced with Svelte, however, I have a small project I started on Friday. Even having resolved all typing errors/etc, I am running into this. I have a much larger project configured nearly identical which doesn't have the issues but is operating with the node adapter. I am not terribly concerned about resolving it for myself, but if the project would be helpful for inspection, I can mark the repo public.

If you can make the small project public that would be super helpful

@gwilson152
Copy link

gwilson152 commented Apr 29, 2025

Here it is, sorry that was slow... Interestingly, I don't think I'm having issues with the server anymore. I didn't really do many commits today, and there were a lot of changes in-between, but I did copy much of my tsconfig.json and I think I changed some things in package.json to match my other project which was not having the issues. Busy day, and it's been on the side, so I'm sorry I can't be more specific.

I can say, it seems to run okay for a while before it would hang up, and it always seemed sluggish compared to my other project which is huge by comparison. I hope this helps - let me know if you have any questions.

https://github.com/gwilson152/TimeVault-Svelte

@jasonlyu123
Copy link
Member

109.6.0 has reduced memory usage in larger projects. Can you check if that prevents the crash for you?

@MrWaip
Copy link
Author

MrWaip commented May 3, 2025

I launched lsp 109.6.0 on my project and it stopped crashing. The memory took up 1.82 - 1.5 GB. Thank you very much for investigating the problem

@dummdidumm
Copy link
Member

Great to hear! I'll close this then, feel free to open a new issue if this comes up again or ping in this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants