Skip to content

MockAgent causes memory leak when used with fuzzing #4715

@willfarrell

Description

@willfarrell

Bug Description

When using MockAgent alongside fuzz testing it was found that a memory leak started happening.

Reproducible By

https://github.com/middyjs/middy/blob/620fdf7c6275708e587e8b223ae6c3d4848267e3/packages/s3-object-response/index.fuzz.js

Expected Behavior

Expected a memory leak not to happen.

Reverted back to using:

global.fetch = (url, request) => {
	return Promise.resolve(
		new Response("", {
			status: 200,
			statusText: "OK",
			headers: new Headers({
				"Content-Type": "application/json; charset=UTF-8",
			}),
		}),
	);
};

Logs & Screenshots

https://github.com/middyjs/middy/actions/runs/20599570479/job/59161706234
https://github.com/middyjs/middy/actions/runs/20599603819/job/59172523477
https://github.com/middyjs/middy/actions/runs/20610082297/job/59192953759

Environment

Node v24.12.0 running on GitHub Actions

Full setup: https://github.com/middyjs/middy/blob/develop/.github/workflows/test-dast.yml

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions