GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Circular declarations cause infinite loops in getExportInfos since v5.5 · Issue #59201 · microsoft/TypeScript

Circular declarations cause infinite loops in getExportInfos since v5.5 #59201

New issue
Copy link
New issue
Copy link
Closed
#59215
Closed
Circular declarations cause infinite loops in getExportInfos since v5.5#59201
#59215
Copy link
Assignees
andrewbranch
Labels
BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issue
Milestone
TypeScript 5.5.4

Description

@simon-paris
Simon Paris (simon-paris)
opened on Jul 9, 2024
Issue body actions

🔎 Search Terms

infinite loop, circular, infinite loop, getExportInfos, invalid array length

🕗 Version & Regression Information

  • This is an infinite loop in tsserver, eventually leading to a crash due to creating an infinitely sized array.
  • This changed between versions 5.5.0-dev.20240508 and 5.5.0-dev.20240509
  • Probably this pr: Refactor default export info name gathering #58460

⏯ Playground Link

Does not reproduce on playground

💻 Code

In an empty folder, place this code in types.d.ts

declare module "mymod" {
  import mymod from "mymod";
  export default mymod;
}

In another file index.ts, trigger an autocomplete or getCodeFixes. Typing two characters into an empty file will usually work. It will hang.

🙁 Actual behavior

The LSP server go into an infinite loop and hangs. After about 20 seconds it'll throw because an array gets too big.

The server log contains:

    RangeError: Invalid array length
        at Array.push (<anonymous>)
        at append (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:2822:6)
        at forEachNameOfDefaultExport (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:138888:13)
        at /Users/myusername/mweb/node_modules/typescript/lib/typescript.js:155493:115
        at /Users/myusername/mweb/node_modules/typescript/lib/typescript.js:138720:119
        at forEachExternalModule (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:138763:7)
        at forEachExternalModuleToImportFrom (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:138720:3)
        at getExportInfos (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:155488:3)
        at /Users/myusername/mweb/node_modules/typescript/lib/typescript.js:155424:24
        at flatMap (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:2502:17)
        at getFixesInfoForNonUMDImport (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:155418:10)
        at getFixInfos (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:155254:12)
        at Object.getCodeActions (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:154389:18)
        at /Users/myusername/mweb/node_modules/typescript/lib/typescript.js:151448:46
        at flatMap (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:2502:17)
        at Object.getFixes (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:151448:10)
        at /Users/myusername/mweb/node_modules/typescript/lib/typescript.js:149730:33
        at flatMap (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:2502:17)
        at Object.getCodeFixesAtPosition (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:149728:12)
        at IpcIOSession.getCodeFixes (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:191339:50)
        at getCodeFixes (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:189374:43)
        at /Users/myusername/mweb/node_modules/typescript/lib/typescript.js:191661:15
        at IpcIOSession.executeWithRequestId (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:191650:14)
        at IpcIOSession.executeCommand (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:191659:29)
        at IpcIOSession.onMessage (/Users/myusername/mweb/node_modules/typescript/lib/typescript.js:191707:68)
        at process.<anonymous> (/Users/myusername/mweb/node_modules/typescript/lib/tsserver.js:525:14)
        at process.emit (node:events:514:28)
        at emit (node:internal/child_process:951:14)
        at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
Screenshot 2024-07-09 at 10 06 41 PM

🙂 Expected behavior

Nothing should happen.

Additional information about the issue

No response

Activity

  1. Andarist commented on Jul 9, 2024

    @Andarist
    Mateusz Burzyński (Andarist)
    on Jul 9, 2024
    Contributor
    More actions

    Cc Andrew Branch (@andrewbranch)

  2. andrewbranch commented on Jul 9, 2024

    @andrewbranch
    Andrew Branch (andrewbranch)
    on Jul 9, 2024
    Member
    More actions
    declare module "mymod" {
      import mymod from "mymod";
      export default mymod;
    }

    What is this supposed to mean?

    Reacted by uhyo and Isabel Duan
  3. Andrew Branch (andrewbranch)
    self-assigned this
    on Jul 9, 2024
  4. Andrew Branch (andrewbranch)
    added
    BugA bug in TypeScript
    CrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output
    on Jul 9, 2024
  5. Andrew Branch (andrewbranch)
    added this to the TypeScript 5.5.4 milestone on Jul 9, 2024
  6. simon-paris commented on Jul 9, 2024

    @simon-paris
    Simon Paris (simon-paris)
    on Jul 9, 2024
    Author
    More actions

    What is this supposed to mean?

    It's nonsense from a dev who was new to typescript, a long time ago. I'm just reporting it anyways because its a crash.

    Reacted by Andrew Branch
  7. andrewbranch commented on Jul 9, 2024

    @andrewbranch
    Andrew Branch (andrewbranch)
    on Jul 9, 2024
    Member
    More actions

    Makes sense, I was just wondering if this was a simplification of something found in a library.

  8. TypeScript Bot (typescript-bot)
    added
    Fix AvailableA PR has been opened for this issue
    on Jul 10, 2024
  9. Andrew Branch (andrewbranch)
    closed this as completedin #59215on Jul 10, 2024
  10. microsoft
    locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @andrewbranch
    Andrew Branch (andrewbranch)

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Milestone

    • TypeScript 5.5.4

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.