Skip to content

[BUG]: Endpoints union types causes tsc to abort with out of memory error #666

Open
@MisanthropicBit

Description

@MisanthropicBit

What happened?

I'm building docker images for two projects which both has a dependency (my project as well) that in turn depends on a bunch of @octokit packages including @octokit/types. However, it started getting oom errors from tsc --emitDeclarationOnly.

When debugging the issue, I ran tsc --emitDeclarationOnly --generateTrace trace-folder to get a trace.json and types.json file (see instructions here). Examining the trace revealed that tsc is has very deep recursive events for type-checking the Endpoints type in the checkSourceFile with an event called traceUnionsOrIntersectionsTooLarge_DepthLimit.

I haven't found a viable solution since I can't tell typescript to ignore type-checking of @octokit/types only. The --skipLibCheck option has no effect, possibly because the package is indirectly included in the source code through imports. Adding NODE_OPTIONS="--max-old-space-size=4096" to the docker build or increasing the memory limit in Docker Desktop solves the issue but is more symptom treatment than a cure. This might be an issue with the typescript compiler, although a large recursive type would explain the oom error, so I'll submit some info to them as well.

Interestingly, eslint also runs out of memory at times. EDIT: This might be because I also have typescript-eslint installed which calls the typescript's typechecking APIs to enable type-aware linting.

An aside: The link to your code of conduct in the issue template is broken.

Versions

Versions as given in a direct dependency for both projects.

  • @octokit/auth-app: "^7.1.5"
  • @octokit/core: "^6.1.4"
  • @octokit/plugin-paginate-rest: "^11.4.2"
  • @octokit/plugin-retry: "^7.1.4"
  • @octokit/plugin-throttling: "^9.4.0"
  • @octokit/types: "^13.8.0"
  • typescript: "^5.5.3"
  • @typescript-eslint/eslint-plugin: "7.6.0",
  • @typescript-eslint/parser: "7.6.0",

Relevant log output

0.822 > tsc --emitDeclarationOnly
0.822
57.23
57.23 <--- Last few GCs --->
57.23
57.23 [19:0x56cf2e0]    55901 ms: Scavenge 2044.1 (2079.4) -> 2043.1 (2081.4) MB, 2.45 / 0.00 ms  (average mu = 0.264, current mu = 0.241) allocation failure;
57.23 [19:0x56cf2e0]    55925 ms: Scavenge 2045.1 (2081.4) -> 2044.0 (2081.4) MB, 3.10 / 0.00 ms  (average mu = 0.264, current mu = 0.241) allocation failure;
57.23 [19:0x56cf2e0]    55942 ms: Scavenge 2045.1 (2081.4) -> 2044.2 (2082.7) MB, 8.14 / 0.00 ms  (average mu = 0.264, current mu = 0.241) allocation failure;
57.23
57.23
57.23 <--- JS stacktrace --->
57.23
57.23 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
57.23 ----- Native stack trace -----
57.23
57.24  1: 0xb8d0a3 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
57.24  2: 0xf062e0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
57.24  3: 0xf065c7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
57.24  4: 0x1118165  [node]
57.24  5: 0x11186f4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
57.24  6: 0x112f5e4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
57.24  7: 0x112fdfc v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
57.24  8: 0x1131f5a v8::internal::Heap::HandleGCRequest() [node]
57.25  9: 0x109d5c7 v8::internal::StackGuard::HandleInterrupts() [node]
57.25 10: 0x153fec2 v8::internal::Runtime_StackGuardWithGap(int, unsigned long*, v8::internal::Isolate*) [node]
57.25 11: 0xffffb9d59ef6
57.34 Aborted

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Needs infoFull requirements are not yet known, so implementation should not be startedType: BugSomething isn't working as documented, or is being fixed

    Type

    No type

    Projects

    Status

    🏗 In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions