Open
Description
Expected Behavior
Do not throw an error.
Current Behavior
Throws an error.
Code snippet
import {RetryAgent, ProxyAgent} from 'undici';
const agent = new RetryAgent(
new ProxyAgent({
token: `Basic <SOME SECRET PASSWORD>`,
uri: `http://our-proxy-url:8080`,
}),
);
agent.request(<call to the API>);
Steps to Reproduce
- Have an environment where you can only access the internet through a proxy
- Instantiate tracer with "captureHTTPsRequests: false,"
- Instantiate agent (see code snippet)
- Call
tracer.provider.instrumentFetch()
<= just to narrow down, that it is this path we are going instead ofcaptureHTTPsGlobal()
- Call some api with the proxy agent
Possible Solution
Looking at
it seems that the diagnostics channel returns the proxy url asorigin
and the url we try to call as path
which seems to be wrong.And this can obviously not be parsed as url and an error gets thrown.
When using getRequestUrl
in
So a possible solution I could imagine would be to not parse the URL but to just return a string or an object based on the diagnostics channel data.
Powertools for AWS Lambda (TypeScript) version
2.22.0
AWS Lambda function runtime
22.x
Packaging format used
npm
Execution logs
{
"errorType": "TypeError",
"errorMessage": "Invalid URL",
"code": "ERR_INVALID_URL",
"input": "http://<PROXY_URL>:8080api.github.com:443",
"stack": [
"TypeError: Invalid URL",
" at new URL (node:internal/url:818:25)",
" at getRequestURL (/node_modules/@aws-lambda-powertools/tracer/lib/esm/provider/utilities.js:46:16)",
" at onRequestStart (/node_modules/@aws-lambda-powertools/tracer/lib/esm/provider/ProviderService.js:77:32)",
" at Channel.publish (node:diagnostics_channel:150:9)",
" at new Request (/node_modules/undici/lib/core/request.js:192:23)",
" at Client.[dispatch] (/node_modules/undici/lib/dispatcher/client.js:300:21)",
" at Client.dispatch (/node_modules/undici/lib/dispatcher/dispatcher-base.js:148:28)",
" at Pool.[dispatch] (/node_modules/undici/lib/dispatcher/pool-base.js:140:28)",
" at Pool.dispatch (/node_modules/undici/lib/dispatcher/dispatcher-base.js:148:28)",
" at Pool.connect (/node_modules/undici/lib/api/api-connect.js:100:10)"
]
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Working on it