apache / apache/netbeans

[JS] StackOverflowError when trying to see function declaration

Open
#5,032 2 comments 0 reactions 0 assignees View on GitHub
JavaScript kind:bug needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 15

### What happened

That is a general error that happens to me frequently when trying to navigate to declaration while working on JS code. I can't provide exact code to reproduce, but here is the stack:

```
java.lang.StackOverflowError
at java.base/java.util.HashMap.hash(HashMap.java:340)
at java.base/java.util.HashMap.getNode(HashMap.java:570)
at java.base/java.util.LinkedHashMap.get(LinkedHashMap.java:441)
at org.netbeans.modules.javascript2.model.api.Index.getCachedValue(Index.java:246)
at org.netbeans.modules.javascript2.model.api.Index.query(Index.java:185)
at org.netbeans.modules.javascript2.model.api.Index.findByFqn(Index.java:412)
at org.netbeans.modules.javascript2.editor.navigation.DeclarationFinderImpl.findPropertyOfType(DeclarationFinderImpl.java:301)
at org.netbeans.modules.javascript2.editor.navigation.DeclarationFinderImpl.findPropertyOfType(DeclarationFinderImpl.java:311)
at org.netbeans.modules.javascript2.editor.navigation.DeclarationFinderImpl.findPropertyOfType(DeclarationFinderImpl.java:311)
at org.netbeans.modules.javascript2.editor.navigation.DeclarationFinderImpl.findPropertyOfType(DeclarationFinderImpl.java:311)
.... and so on many times
```

### How to reproduce

_No response_

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Windows 10

### JDK

16.0.1

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

_No response_

### Are you willing to submit a pull request?

Yes

### Code of Conduct

Yes

Contributor guide

Open the contributing guide

Research direction

Start with org.netbeans.modules.javascript2.editor.navigation.DeclarationFinderImpl.findPropertyOfType, then trace its recursive calls into javascript2.model.api.Index.query and findByFqn. Try reproducing declaration navigation on JavaScript code and use the reported stack trace as the initial checkpoint; done means navigation no longer produces a StackOverflowError.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, javascript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.