question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript 4.5 Beta infinite loop leading to JS heap out of memory

See original GitHub issue

An issue appeared with TypeScript 4.5.0-dev.20211001 that made tsc go into an infinite loop leading to an out-of-memory error.

tsconfig.json:

{
  "compilerOptions": {
    "target": "es2020",
    "module": "commonjs",
    "moduleResolution": "node",
    "lib": ["es2020"]
  },
  "exclude": ["node_modules"],
  "include": ["run.ts"]
}

package.json:

{
  "type": "commonjs",
  "scripts": {
    "start": "tsc -p ."
  },
  "dependencies": {
    "zod": "^3.9.8"
  },
  "devDependencies": {
    "typescript": "^4.5.0-beta"
  }

when using tsc directly, the following import cause the issue:

import { z } from "zod";

when using ts-node instead of tsc, this is the minimum necessary code to cause the issue:

import { z } from "zod";

const schema: z.ZodSchema<string> = z.string();

Demo code in: https://github.com/mmvsk/bug-zod-typescript-4.5.0-oct-01

The same code works until TypeScript 4.5.0-dev.20210930, and the issue was probably introduced with the following TypeScript PR: https://github.com/microsoft/TypeScript/pull/41821

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
colinhackscommented, Oct 19, 2021

Happy to see that fix land. I struggled to solve that issue for most of Saturday and made minimal progress. The DeepPartial thing is a much easier fix, I’ll look into it when I have a chance.

0reactions
maxmvskcommented, Oct 19, 2021

Well, there is progress.

TypeScript was fixed (in https://github.com/microsoft/TypeScript/pull/46326), so now we have a clear error message instead of a memory error.

I created a new issue #715.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript heap out of memory - angular
I solved the error by adding NODE_OPTIONS='--max-old-space-size=4096' to the build script in package.json as shown in the following example.
Read more >
Documentation - TypeScript 4.5
These declaration files represent the available APIs in the JavaScript language, and the standard browser DOM APIs. While there are some reasonable defaults ......
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
o.lock to be removed" displayed by libtool in infinite loop (e.g. ... amd64 due to out of memory error" status:RESOLVED resolution:OBSOLETE severity:normal ...
Read more >
Top 5 Performance Metrics for Node.js Applications
Monitor and visualize Node.js application performance with these top five ... the heap memory usage should be completely flushed out.
Read more >
Release notes and release history for Mobiscroll
... initial value for the time picker resulted in an infinite loop in Angular. ... We fixed the typescript type of the segmented...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found