Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zod v4 compilation causes JavaScript heap out of memory #5204

@aldex32

Description

@aldex32

I am using [email protected] together with @aws-lambda-powertools/[email protected].

I'm getting heap out of memory during compilation when import statement is:

import { z } from 'zod';

If I change the import to zod/v4, the OOM is solved, but I get compilation issues since imports in @aws-lambda-powertools are import { z } from 'zod';

Here is a reproducibile issue:

import { z, ZodType } from 'zod/v4';
import { JSONStringified } from '@aws-lambda-powertools/parser/helpers';

const apiGatewayEventSchema = <T extends ZodType>(bodySchema: T) => {
    return z.object({
        body: JSONStringified(bodySchema),
    });
};

I don't understand why the issue #4952 was closed. This is blocking the migration to version 4 unfortunately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions