aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
2.97k stars 556 forks source link

Application stack trace is not shown #5988

Closed dimonnwc3 closed 2 months ago

dimonnwc3 commented 2 months ago

Checkboxes for prior research

Describe the bug

While using aws s3 send method, with any command producing the error. Error stack trace points to some internal AWS library code rather than application code where send methid is called.

SDK version number

@aws-sdk/client-s3@3.552.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v21.6.2

Reproduction Steps

call s3 client send method with any command that throws an error

for example:

import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3"

export const s3Client = new S3Client()

await s3Client.send(
  new GetObjectCommand({
    Bucket: "bucketName",
    Key: "unknown",
  }),
)

Observed Behavior

here is example stack trace, which shows some internal of the library, but doesn't include my application code

/Users/dimonn/sandbox/test/node_modules/@smithy/smithy-client/dist-cjs/index.js:838
  const response = new exceptionCtor({
                   ^

PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
    at throwDefaultError (/Users/dimonn/sandbox/test/node_modules/@smithy/smithy-client/dist-cjs/index.js:838:20)
    at /Users/dimonn/sandbox/test/node_modules/@smithy/smithy-client/dist-cjs/index.js:847:5
    at de_CommandError (/Users/dimonn/sandbox/test/node_modules/@aws-sdk/client-s3/dist-cjs/index.js:4756:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/dimonn/sandbox/test/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
    at async /Users/dimonn/sandbox/test/node_modules/@aws-sdk/middleware-signing/dist-cjs/index.js:225:18
    at async /Users/dimonn/sandbox/test/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
    at async /Users/dimonn/sandbox/test/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:173:18
    at async /Users/dimonn/sandbox/test/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:97:20
    at async /Users/dimonn/sandbox/test/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:120:14 {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 301,
    requestId: 'ZCWE2NJ9XZH0X98N',
    extendedRequestId: 'gL1X0o1IpLrxn1qj/qw9kZSkwHF+RsOZr2hZEOZEtmrvjY+8fKkLgFE23v9i/KMxgYW+s7DT4GM=',
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Code: 'PermanentRedirect',
  Endpoint: 's3.amazonaws.com',
  Bucket: 'bucketName',
  RequestId: 'ZCWE2NJ9XZH0X98N',
  HostId: 'gL1X0o1IpLrxn1qj/qw9kZSkwHF+RsOZr2hZEOZEtmrvjY+8fKkLgFE23v9i/KMxgYW+s7DT4GM='
}

Expected Behavior

I expect stack trace to show where error happens in my application code

example when I throw error by myself, stack trace shows exact error in my code

file:///Users/dimonn/sandbox/test/s3.js:5
throw new Error("aaa")
      ^

Error: aaa
    at file:///Users/dimonn/sandbox/test/s3.js:5:7
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:120:12

Possible Solution

No response

Additional Information/Context

No response

kuhe commented 2 months ago

increase the stack trace limit with https://nodejs.org/api/errors.html#errorstacktracelimit.

dimonnwc3 commented 2 months ago

I tried but nothing is changed

RanVaknin commented 2 months ago

Hi @dimonnwc3 ,

What you are describing here is not unique to the SDK. This is known limitation of NodeJS as explained here. This is a common challenge with async programming in JS and is due to v8's zero cost async stack traces. You can try running your application with $ node --async-stack-traces codeSnippet.js to see if it solves your problem.

Since this is not an SDK issue, and not actionable by the SDK team Im going to go ahead and close this issue.

Thanks for taking the time and reaching out.

All the best, Ran~

github-actions[bot] commented 2 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.