Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

cdktf synth out of memory #3945

@arruw

Description

@arruw

Expected Behavior

HCL files generated

Actual Behavior

$ cdktf synth --hcl --log-level info
runtime: out of memory: cannot allocate 792723456-byte block (3279781888 in use)
fatal error: out of memory

goroutine 6 [running]:
runtime.throw({0x3f240, 0xd})
        /opt/golang/go/src/runtime/panic.go:992 +0x7 fp=0x4fd5c0 sp=0x4fd598 pc=0x12080007
runtime.(*mcache).allocLarge(0x270108, 0x2f10a000, 0x0)
        /opt/golang/go/src/runtime/mcache.go:215 +0x31 fp=0x4fd610 sp=0x4fd5c0 pc=0x10e80031
runtime.mallocgc(0x2f10a000, 0x2a2e0, 0x1)
        /opt/golang/go/src/runtime/malloc.go:1096 +0x8b fp=0x4fd690 sp=0x4fd610 pc=0x109f008b
runtime.growslice(0x2a2e0, {0xaa000000, 0x646700, 0x646700}, 0x646701)
        /opt/golang/go/src/runtime/slice.go:278 +0x89 fp=0x4fd6e0 sp=0x4fd690 pc=0x12c80089
github.com/hashicorp/hcl/v2/hclsyntax.(*tokenAccum).emitToken(0x4fdb20, 0xbb, 0x27c9fad, 0x27c9fae)
        /github/home/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclsyntax/token.go:154 +0x14 fp=0x4fd7e8 sp=0x4fd6e0 pc=0x1ac60014
github.com/hashicorp/hcl/v2/hclsyntax.scanTokens.func1(...)
        scan_tokens.rl:348
github.com/hashicorp/hcl/v2/hclsyntax.scanTokens({0xc00000, 0x4eb5709, 0x4eb6000}, {0x0, 0x0}, {0x1, 0x1, 0x0}, 0x0)
        scan_tokens.rl:86 +0x120 fp=0x4fdb88 sp=0x4fd7e8 pc=0x1ac40120
github.com/hashicorp/hcl/v2/hclsyntax.LexConfig({0xc00000, 0x4eb5709, 0x4eb6000}, {0x0, 0x0}, {0x1, 0x1, 0x0})
        /github/home/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclsyntax/public.go:129 +0x2 fp=0x4fdc08 sp=0x4fdb88 pc=0x1ac30002
github.com/hashicorp/hcl/v2/hclwrite.lexConfig({0xc00000, 0x4eb5709, 0x4eb6000})
        /github/home/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/parser.go:639 +0x2 fp=0x4fdd58 sp=0x4fdc08 pc=0x1ad40002
github.com/hashicorp/hcl/v2/hclwrite.Format({0xc00000, 0x4eb5709, 0x4eb6000})
        /github/home/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/public.go:42 +0x2 fp=0x4fddc0 sp=0x4fdd58 pc=0x1ad50002
main.main.func1({{}, 0x0, 0x0}, {0x42c120, 0x1, 0x2})
        /__w/terraform-cdk/terraform-cdk/packages/@cdktf/hcl-tools/main.go:58 +0x7 fp=0x4fde00 sp=0x4fddc0 pc=0x1ae20007
main.registrationWrapper.func1({{}, 0x0, 0x0}, {0x42c120, 0x2, 0x2})
        /__w/terraform-cdk/terraform-cdk/packages/@cdktf/hcl-tools/main.go:27 +0x5 fp=0x4fdec0 sp=0x4fde00 pc=0x1ae00005
syscall/js.handleEvent()
        /opt/golang/go/src/syscall/js/func.go:94 +0x26 fp=0x4fdf90 sp=0x4fdec0 pc=0x15840026
runtime.handleEvent()
        /opt/golang/go/src/runtime/lock_js.go:243 +0x14 fp=0x4fdfe0 sp=0x4fdf90 pc=0x10960014
runtime.goexit()
        /opt/golang/go/src/runtime/asm_wasm.s:401 +0x1 fp=0x4fdfe8 sp=0x4fdfe0 pc=0x13c80001
created by runtime.beforeIdle
        /opt/golang/go/src/runtime/lock_js.go:199 +0x1a

goroutine 1 [chan receive]:
exit code: 2

Steps to Reproduce

  1. Have huge monorepo workspace managing DataDog resources (10k+ resources)
  2. Run cdktf synth --hcl --log-level info

Versions

We are using uv and not pipenv, seems like cdktf debug have strong dependency on pipenv:

$ cdktf debug
[2025-11-27T20:36:09.649] [ERROR] default - Loading .env environment variables...

Loading .env environment variables...
[2025-11-27T20:36:09.650] [ERROR] default - WARNING:pipenv.vendor.dotenv.main:Python-dotenv could not parse statement starting at line 1
WARNING:pipenv.vendor.dotenv.main:Python-dotenv could not parse statement starting at line 2
Courtesy Notice:
Pipenv found itself running within a virtual environment,  so it will 
automatically use that environment, instead of  creating its own for any 
project. You can set
PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and 
create  its own instead.
You can set PIPENV_VERBOSITY=-1 to suppress this warning.

WARNING:pipenv.vendor.dotenv.main:Python-dotenv could not parse statement starting at line 1
WARNING:pipenv.vendor.dotenv.main:Python-dotenv could not parse statement starting at line 2
Courtesy Notice:
Pipenv found itself running within a virtual environment,  so it will 
automatically use that environment, instead of  creating its own for any 
project. You can set
PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and 
create  its own instead.
You can set PIPENV_VERBOSITY=-1 to suppress this warning.
[2025-11-27T20:36:10.252] [ERROR] default - WARNING: Package(s) not found: cdktf

WARNING: Package(s) not found: cdktf
[2025-11-27T20:36:10.861] [ERROR] default - WARNING: Package(s) not found: cdktf

WARNING: Package(s) not found: cdktf
cdktf --version
0.21.0

$ terraform --version
Terraform v1.11.4
on darwin_arm64

$ python --version
Python 3.9.24

$ node --version
v24.7.0

Providers

cdktf provider list fails with similar error as cdktf debug

we use only one tf provider:

  • "cdktf-cdktf-provider-datadog>=12.10.0"

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnewUn-triaged issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions