-
Notifications
You must be signed in to change notification settings - Fork 163
Closed
Labels
bugSomething isn't workingSomething isn't workingcompletedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedtracerThis item relates to the Tracer UtilityThis item relates to the Tracer Utility
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
const getRequestURL = ( |
origin
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
const requestURL = getRequestURL(request); |
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)"
]
}
daschaa
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcompletedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedtracerThis item relates to the Tracer UtilityThis item relates to the Tracer Utility
Type
Projects
Status
Shipped