Description
Upgrading the AWS Lambda layer to the new unified architecture causes the Lambda function to hang indefinitely and hit its hard timeout limit. This regression occurs specifically when utilizing fetch with a custom undici Agent dispatcher configured to bypass certificate verification or handle self-signed endpoints.
Expected Behavior
The fetch request should execute, complete, and allow the Lambda function handler to resolve cleanly, as it did in the previous runtime-specific layer version.
Actual Behavior
The execution thread completely freezes at the moment of the fetch request call. The Lambda function sits in an unresolved state until the AWS Lambda execution timeout triggers.
Steps to Reproduce
Configure a Node.js 22 Lambda function with the following minimal setup:
import { fetch, Agent } from 'undici';
const customAgent = new Agent({
connect: { rejectUnauthorized: false }
});
export const handler = async (event) => {
// Execution freezes exactly right here
const response = await fetch('https://my-self-signed-site.local', {
dispatcher: customAgent
});
return await response.json();
};
Troubleshooting and Isolation
- Feature Flag Isolation: Setting the environment variable
NEW_RELIC_INSTRUMENTATION_UNDICI_ENABLED: false completely resolves the issue. The function instantly runs and closes without timing out.
- Dispatcher Isolation: Leaving instrumentation enabled but commenting out the
dispatcher: customAgent argument from the fetch options object also stops the timeout (though it obviously fails TLS verification for our target server). The loop lock is strictly linked to how the agent patches the custom Agent object.
- Symptom: It behaves as an internal unresolved promise chain or an infinite event loop block created when the monkey-patch wrapper attempts to parse explicit
dispatcher runtime configuration properties in Node 22.
Relevant Logs / Console output
I attempted to gather diagnostic logs by setting NEW_RELIC_LOG_ENABLED: true, NEW_RELIC_LOG: stdout, and NEW_RELIC_LOG_LEVEL: trace.
Despite enabling maximum verbosity, the agent does not output any explicit error traces, crashes, or unhandled exceptions before freezing. The execution loop simply stalls out silently, and the only log received in AWS CloudWatch is the standard hard timeout warning emitted by the AWS Lambda runtime itself:
REPORT RequestId: ... Duration: 15003.45 ms Billed Duration: 15000 ms Memory Size: 512 MB Max Memory Used: ...
2026-05-20T...Z ... Task timed out after 15.00 seconds
Your Environment
- AWS Lambda Runtime: Node.js 22.x
- Undici Package Version: 6.24.0
- Working Layer ARN:
arn:aws:lambda:eu-west-1:451483290750:layer:NewRelicNodeJS22XARM64:22
- Broken Layer ARN:
arn:aws:lambda:eu-west-1:451483290750:layer:NewRelicNodeJSARM64:10
- Agent Framework Delta: Transitioning from the legacy runtime-pinned
Description
Upgrading the AWS Lambda layer to the new unified architecture causes the Lambda function to hang indefinitely and hit its hard timeout limit. This regression occurs specifically when utilizing
fetchwith a customundiciAgentdispatcher configured to bypass certificate verification or handle self-signed endpoints.Expected Behavior
The
fetchrequest should execute, complete, and allow the Lambda function handler to resolve cleanly, as it did in the previous runtime-specific layer version.Actual Behavior
The execution thread completely freezes at the moment of the
fetchrequest call. The Lambda function sits in an unresolved state until the AWS Lambda execution timeout triggers.Steps to Reproduce
Configure a Node.js 22 Lambda function with the following minimal setup:
Troubleshooting and Isolation
NEW_RELIC_INSTRUMENTATION_UNDICI_ENABLED: falsecompletely resolves the issue. The function instantly runs and closes without timing out.dispatcher: customAgentargument from thefetchoptions object also stops the timeout (though it obviously fails TLS verification for our target server). The loop lock is strictly linked to how the agent patches the customAgentobject.dispatcherruntime configuration properties in Node 22.Relevant Logs / Console output
I attempted to gather diagnostic logs by setting
NEW_RELIC_LOG_ENABLED: true,NEW_RELIC_LOG: stdout, andNEW_RELIC_LOG_LEVEL: trace.Despite enabling maximum verbosity, the agent does not output any explicit error traces, crashes, or unhandled exceptions before freezing. The execution loop simply stalls out silently, and the only log received in AWS CloudWatch is the standard hard timeout warning emitted by the AWS Lambda runtime itself:
Your Environment
arn:aws:lambda:eu-west-1:451483290750:layer:NewRelicNodeJS22XARM64:22arn:aws:lambda:eu-west-1:451483290750:layer:NewRelicNodeJSARM64:10