-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read properties of undefined (reading 'hostname')
in @aws-sdk/client-s3 instrumentation
#3464
Comments
@AndKiel For what it is worth, I cannot repro using: const {
S3Client,
GetObjectCommand,
} = require('@aws-sdk/client-s3')
const { getSignedUrl } = require('@aws-sdk/s3-request-presigner')
...
command = new GetObjectCommand({ Bucket: bucketName, Key: key })
const signedUrl = await getSignedUrl(s3Client, command, { expiresIn: 3600 })
console.log('signedUrl: ', signedUrl)
... I'm using the latest elastic-apm-node (the HEAD of the "main" git branch), and |
The full stack trace we got would be:
It happened on a graphQL field resolver that's supposed to return a signed URL for downloading a file. What we're doing boils down to the: import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
// In our code client is cached in a global injectable service (we're using typedi)
const s3 = new S3Client({ region: "us-east-1" })
// That global service is a wrapper and it does signing just like your snippet above
getSignedUrl(s3, new GetObjectCommand({ Bucket, Key }), { expiresIn: 60 * 60 * 24 * 7 }); As mentioned, we were on 3.332.0 version of aws packages. |
@AndKiel Thanks. I was able to reproduce, finally. The subtlety is that there needs to be a current APM span when the I'll get a fix together soon. implementation detailsOur instrumentation does this:
The first surprise is that However, here are two others (the only two others I could find):
The result with
Fixing either of those cases deals with this issue, but I'll have a PR that addresses both. |
In #3454 (comment) it was reported that instrumentation of
@aws-sdk/client-s3
could throw:@AndKiel Thanks for reporting this! Instrumentation of
@aws-sdk/client-s3
was first added in v3.46.0 of this APM agent. I'm almost certain this is a separate issue from #3454, so I have moved it here.If you had a small reproduction script, or even just a small snippet of JavaScript code showing the S3 Client API calls that hit this, that would be very helpful for me attempting to reproduce.
Our instrumentation is adding aws-sdk v3 middleware -- to the "initialize" and "finalizeRequest" steps. The error above could happen if the "finalizeRequest" step is not run for a particular client call.
The text was updated successfully, but these errors were encountered: