Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions lib/tracing/cloud_sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,22 @@ module.exports = () => {

const cloudSDK = require('@sap-cloud-sdk/http-client')
const { executeHttpRequest: _execute, executeHttpRequestWithOrigin: _executeWithOrigin } = cloudSDK
cloudSDK.executeHttpRequest = wrap(_execute, {
const _executeHttpRequest = wrap(_execute, {
wrapper: function executeHttpRequest(destination, requestConfig) {
return trace(
_cloudSdkSpanName(destination, requestConfig),
_execute,
this,
arguments,
{ kind: SpanKind.CLIENT, outbound: destination.name }
)
return trace(_cloudSdkSpanName(destination, requestConfig), _execute, this, arguments, {
kind: SpanKind.CLIENT,
outbound: destination.name
})
}
})
cloudSDK.executeHttpRequestWithOrigin = wrap(_executeWithOrigin, {
Object.defineProperty(cloudSDK, 'executeHttpRequest', { value: _executeHttpRequest })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Object.defineProperty without writable: true or configurable: true defaults both to false, making the property non-writable and non-configurable. This is a stricter result than the original simple assignment, and will silently fail (or throw in strict mode) if any downstream code tries to reassign or redefine the property (e.g. in tests or repeated patching).

Suggested change
Object.defineProperty(cloudSDK, 'executeHttpRequest', { value: _executeHttpRequest })
Object.defineProperty(cloudSDK, 'executeHttpRequest', { value: _executeHttpRequest, writable: true, configurable: true })

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

const _executeHttpRequestWithOrigin = wrap(_executeWithOrigin, {
wrapper: function executeHttpRequestWithOrigin(destination, requestConfig) {
return trace(
_cloudSdkSpanName(destination, requestConfig),
_executeWithOrigin,
this,
arguments,
{ kind: SpanKind.CLIENT, outbound: destination.name }
)
return trace(_cloudSdkSpanName(destination, requestConfig), _executeWithOrigin, this, arguments, {
kind: SpanKind.CLIENT,
outbound: destination.name
})
}
})
Object.defineProperty(cloudSDK, 'executeHttpRequestWithOrigin', { value: _executeHttpRequestWithOrigin })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Same issue — writable and configurable default to false, making executeHttpRequestWithOrigin frozen on the module export.

Suggested change
Object.defineProperty(cloudSDK, 'executeHttpRequestWithOrigin', { value: _executeHttpRequestWithOrigin })
Object.defineProperty(cloudSDK, 'executeHttpRequestWithOrigin', { value: _executeHttpRequestWithOrigin, writable: true, configurable: true })

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

}