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

TypeError: Cannot set property message of which has only a getter #6783

Open
3 of 4 tasks
mmayors opened this issue Jan 8, 2025 · 6 comments
Open
3 of 4 tasks

TypeError: Cannot set property message of which has only a getter #6783

mmayors opened this issue Jan 8, 2025 · 6 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue queued This issues is on the AWS team's backlog v2-v3-inconsistency Behavior has changed from v2 to v3, or feature is missing altogether

Comments

@mmayors
Copy link

mmayors commented Jan 8, 2025

Checkboxes for prior research

Describe the bug

After migrating our v2 SDK clients to v3, we're seeing this specific error sporadically but frequently when sending a command:

Cannot set property message of  which has only a getter
 
TypeError: Cannot set property message of  which has only a getter
    at message (webpack://.../node_modules/@smithy/middleware-serde/dist-es/deserializerMiddleware.js:16:18)
    at output (webpack://.../node_modules/@smithy/core/dist-es/middleware-http-signing/httpSigningMiddleware.js:18:10)
    at null (webpack://.../node_modules/@smithy/middleware-retry/dist-es/retryMiddleware.js:27:32)

All @AWS-SDK dependencies in package.json are pinned to 3.716.0. We also explicitly declare @smithy/[email protected] for the ServiceException type.

Based on the stacktrace, this appears to be a deserialization error. But I'm curious if there may be second problem when @smithy/middleware-serde tries appending a hint to the original error message, which appears to be where the error in the stacktrace above originates.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected], @aws-sdk/[email protected], @aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Browser

Details of the browser/Node.js/ReactNative version

Chrome: 131.0.6778.265 Firefox: 133.0.3 Safari: 18.2

Reproduction Steps

This doesn't reproduce every time but it happens most frequently when sending these commands:

@aws-sdk/client-cloudwatch-logs

DescribeLogGroupsCommand

@aws-sdk/client-efs

DescribeFileSystemsCommand
DescribeAccessPointsCommand

@aws-sdk/client-iam

ListRolesCommand

Observed Behavior

Invoking send rejects with the error: Cannot set property message of which has only a getter

Expected Behavior

Invoking send resolves to the API response or rejects with a Smithy ServiceException.

Possible Solution

No response

Additional Information/Context

No response

@mmayors mmayors added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 8, 2025
@zshzbh
Copy link
Contributor

zshzbh commented Jan 10, 2025

Could you please post the package.json and minimal code reproduction of

@aws-sdk/client-iam

ListRolesCommand

in the comment?

Thanks!

@zshzbh zshzbh self-assigned this Jan 10, 2025
@zshzbh zshzbh added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p2 This is a standard priority issue v2-v3-inconsistency Behavior has changed from v2 to v3, or feature is missing altogether and removed needs-triage This issue or PR still needs to be triaged. labels Jan 10, 2025
Copy link

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jan 21, 2025
@kuhe
Copy link
Contributor

kuhe commented Jan 21, 2025

the Error message field is writable by default. Do you have any code changing this behavior?

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. labels Jan 22, 2025
@mmayors
Copy link
Author

mmayors commented Jan 22, 2025

@kuhe We transpile TypeScript to JS using babel but I don't see anything in our babel config that would alter this behavior. I don't have a reproducible sandbox but I can reproduce this within our app. I added console.log statements to node_modules/@smithy/middleware-serde/dist-es/deserializerMiddleware.js and wrapped the line that modifies the original error in a try/catch. I can confirm:

  1. Iam.ListRoles returned a successful response here
  2. When it tried parsing the response here the deserializer function threw a DOMException, which is the original error caught here:

Image

  1. When it tries modifying the original error message here , it throws another error:

    Cannot set property message of which has only a getter

    which might explain why this is the final error returned to the caller.

Some more observations:

  • It doesn't look like a DOMException's message property should be writable: https://developer.mozilla.org/en-US/docs/Web/API/DOMException/message
  • When navigating to a different route, we abort requests with an AbortContoller (passing an abortSignal). But that doesn't explain why a DOMException is thrown while parsing e.g. after getting a successful response.
  • When we abort a request with an AbortController, the error thrown (and caught by deserializerMiddleware.js) isn't a DOMException. It's a generic Error object.

@kuhe kuhe self-assigned this Jan 23, 2025
@kuhe kuhe added the queued This issues is on the AWS team's backlog label Jan 23, 2025
@kuhe
Copy link
Contributor

kuhe commented Jan 24, 2025

I started a release for a patch increment of @smithy/middleware-serde to handle the unwritable error.message field. Since the current version is 4.0.1, the fix should appear as https://www.npmjs.com/package/@smithy/middleware-serde/v/4.0.2 soon.

@kuhe
Copy link
Contributor

kuhe commented Jan 27, 2025

there was a delay in publishing the packages but it's out now: https://www.npmjs.com/package/@smithy/middleware-serde/v/4.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue queued This issues is on the AWS team's backlog v2-v3-inconsistency Behavior has changed from v2 to v3, or feature is missing altogether
Projects
None yet
Development

No branches or pull requests

3 participants