Skip to content
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

Application stack trace being swallowed up #1287

Closed
Bene-Graham opened this issue Jun 22, 2020 · 7 comments
Closed

Application stack trace being swallowed up #1287

Bene-Graham opened this issue Jun 22, 2020 · 7 comments
Assignees
Labels
bug This issue is a bug. High Priority

Comments

@Bene-Graham
Copy link

Describe the bug
In the v2 repo this bug: aws/aws-sdk-js#3020 hinted at that in v3 there was going to be improvement around stack traces. So I decided to run some test wiht the v3 SDK to see if there is any improvements. Currently it does not show where the error was thrown within my application. This make it was hard to track down where the error is occurring.

SDK version number
@aws-sdk/client-s3: 1.0.0-gamma.2

Is the issue in the browser/Node.js?
Node.js

Details of the browser/Node.js version
v12.16.3

To Reproduce (observed behavior)
I created a simple application that should show the current behaviour.
https://github.com/Bene-Graham/AWS-SDK-StackTraceIssue

Expected behavior
I would expect that the stack trace should contain where in my application code the error was thrown. Currently it only show this:

NoSuchKey: NoSuchKey
    at deserializeAws_restXmlGetObjectCommandError (/Users/xyz/Documents/git/Other/AWS-SDK-StackTraceIssue/node_modules/@aws-sdk/client-s3/dist/cjs/protocols/Aws_restXml.js:4868:41)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 404,
    httpHeaders: {
      'x-amz-request-id': '',
      'x-amz-id-2': '',
      'content-type': 'application/xml',
      'transfer-encoding': 'chunked',
      date: 'Mon, 22 Jun 2020 19:50:40 GMT',
      server: 'AmazonS3'
    },
    requestId: undefined,
    retries: 0,
    totalRetryDelay: 0
  }
}
@AllanZhengYP AllanZhengYP added the bug This issue is a bug. label Jun 29, 2020
@AllanZhengYP
Copy link
Contributor

Hi @Bene-Graham

Thank you for reporting this. This is issue usually caused be async function throwing error inside a callback. I will need to take a closer look at it.

@simonbuchan
Copy link
Contributor

A few notes:

Overly transpiling isn't helping, expanding every async/await frame into a set of step(), next(), fulfilled() regenerator runtime frames. To fix you would need to ship at least es2017. You can ship multiple, and ask users to use e.g. webpack resolve.aliasFields = ["es2017", "module", "main"]`, but at this point many packages are simply targeting es2017 and asking people targeting platforms that don't support it (pretty much just IE) to retranspile.

Returning a promise breaks the async stack:

async function foo() { await 0; throw new Error() }
async function bar() { await foo() }
async function baz() { return bar() }
baz().catch(console.log)
Error: 
    at foo (<anonymous>:1:39)
    at async bar (<anonymous>:2:24)
async function foo() { await 0; throw new Error() }
async function bar() { return foo() }
async function baz() { await bar() }
baz().catch(console.log)
Error: 
    at foo (<anonymous>:1:39)

At least in 7.3, when async stack traces were enabled, only await and Promise.all() would reconstruct a stack frame, due to performance: https://v8.dev/docs/stack-trace-api#async-stack-traces

@AllanZhengYP
Copy link
Contributor

Hi @simonbuchan @Bene-Graham,

Thank you for the insights. We have targeted all the Node.js packages to ES2018 in #1572. Here's how the stack trace will look like now:

NoSuchKey: NoSuchKey
    at deserializeAws_restXmlGetObjectCommandError (Path/to/@aws-sdk/client-s3/dist/cjs/protocols/Aws_restXml.js:5311:41)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Path/to/@aws-sdk/middleware-serde/dist/cjs/deserializerMiddleware.js:12:20
    at async Path/to/@aws-sdk/middleware-signing/dist/cjs/middleware.js:12:24
    at async StandardRetryStrategy.retry (Path/to/@aws-sdk/middleware-retry/dist/cjs/defaultStrategy.js:55:46)
    at async Path/to/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22
    at async Path/to/test.js:29:18 {
  name: 'NoSuchKey',
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 404,
    httpHeaders: {
      'x-amz-request-id': '',
      'x-amz-id-2': '',
      'content-type': 'application/xml',
      'transfer-encoding': 'chunked',
      date: '',
      server: 'AmazonS3'
    },
    requestId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
}

This fix will be released very soon.

@Bene-Graham
Copy link
Author

Look forward to trying it out when the next package release happens 😄

@AllanZhengYP
Copy link
Contributor

AllanZhengYP commented Oct 20, 2020

Hi @Bene-Graham, the new version is available now. Please try the newest version @aws-sdk/client-s3 (without @gamma dist tag!). I will resolve this issue now. Please let me know if the issue peresists.

@Bene-Graham
Copy link
Author

That looks a lot better.

Thank You.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. High Priority
Projects
None yet
Development

No branches or pull requests

3 participants