-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Bug (v10.x) - Error: Cannot assign to read only property 'lastResponse' of object
#1796
Comments
Hi @titanism, Does the error reproduce on the latest version of the library? Can you share some code that reproduces the error? |
We cannot reproduce on latest version and it is hard to reproduce, but this definitely happens and has since probably v0.8. |
I'm sorry @titanism but without a stack trace, a repro and with the fact that it doesn't reproduce on latest there isn't much we can do with the issue you are seeing. |
We've been able to reproduce this and the exact cause, will report back with complete findings soon. Note this only applies if you are doing things like creating a new object and re-assigning properties (since |
The issue occurs when you are trying to assign the property The issue is fixed by changing this code: +jsonResponse.lastResponse = rawResponse;
-Object.defineProperty(jsonResponse, 'lastResponse', {
- enumerable: false,
- writable: false,
- value: rawResponse,
});
+// Object.defineProperty(jsonResponse, 'lastResponse', {
+// enumerable: false,
+// writable: false, // NOTE: this is already set to `false` when using `defineProperty`
+// value: rawResponse,
+// }); Per stripe-node/src/RequestSender.ts Lines 188 to 191 in 62fbbc6
Note that |
Closing this ticket, but you may want to re-open or patch this per the above diff as it is common practice for loggers to strip/sanitize/parse/stringify objects. The culprit of this bug was from doing |
Describe the bug
Error: Cannot assign to read only property 'lastResponse' of object
To Reproduce
I think it happens here:
node_modules/stripe/lib/StripeResource.js 102: // lastResponse. 221: Object.defineProperty(jsonResponse, 'lastResponse', {
Expected behavior
This should not throw an error.
Code snippets
No response
OS
macOS
Node version
Node v18
Library version
stripe-node 10.17.0
API version
2020-08-27
Additional context
No response
The text was updated successfully, but these errors were encountered: