Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-joelmut committed Dec 18, 2024
1 parent 698d806 commit d3ab92c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,29 +131,29 @@ export class ServiceClientContext extends ServiceClient {
operationSpec: OperationSpec,
callback?: ServiceCallback<T>,
): Promise<T> {
let resolve: any;
let reject: any;
const result = new Promise<T>((res, rej) => {
resolve = res;
reject = rej;
});
// let resolve: any;
// let reject: any;
// const result = new Promise<T>((res, rej) => {
// resolve = res;
// reject = rej;
// });
const options =
this.createOptions(operationArguments.options as LegacyOperationArguments['options'], callback) ?? {};

const innerOnResponse = options.onResponse;
options.onResponse = (rawResponse, flatResponse, error) => {
innerOnResponse?.(rawResponse, flatResponse, error);
if (error) {
reject(error);
} else {
Object.defineProperty(flatResponse, '_response', {
value: rawResponse,
});
resolve(flatResponse);
}
};

await super.sendOperationRequest<T>({ ...operationArguments, options }, operationSpec);
// const innerOnResponse = options.onResponse;
// options.onResponse = (rawResponse, flatResponse, error) => {
// innerOnResponse?.(rawResponse, flatResponse, error);
// if (error) {
// reject(error);
// } else {
// Object.defineProperty(flatResponse, '_response', {
// value: rawResponse,
// });
// resolve(flatResponse);
// }
// };

const result = await super.sendOperationRequest<T>({ ...operationArguments, options }, operationSpec);
return result;
}

Expand Down Expand Up @@ -192,15 +192,17 @@ export class ServiceClientContext extends ServiceClient {
customHeaders: options?.customHeaders,
timeout: options?.timeout,
shouldDeserialize(response) {
return typeof options?.shouldDeserialize === 'function'
? options?.shouldDeserialize?.(toCompatResponse(response))
: options?.shouldDeserialize === true;
if (typeof options?.shouldDeserialize === 'function') {
return options?.shouldDeserialize?.(toCompatResponse(response));
} else if (typeof options?.shouldDeserialize === 'boolean') {
return options?.shouldDeserialize;
}
return true;
},
onDownloadProgress: options?.onDownloadProgress,
onUploadProgress: options?.onUploadProgress,
},
onResponse(rawResponse: any, flatResponse, error) {
const args = [];
typeof options === 'function' ??
(options as ServiceCallback<any>)?.(
error as Error,
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
dependencies:
tslib "^1.9.3"

"@azure/abort-controller@^2.0.0":
"@azure/abort-controller@^2.0.0", "@azure/abort-controller@^2.1.2":
version "2.1.2"
resolved "https://registry.yarnpkg.com/@azure/abort-controller/-/abort-controller-2.1.2.tgz#42fe0ccab23841d9905812c58f1082d27784566d"
integrity sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==
Expand Down Expand Up @@ -129,6 +129,13 @@
dependencies:
tslib "^2.6.2"

"@azure/core-tracing@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@azure/core-tracing/-/core-tracing-1.2.0.tgz#7be5d53c3522d639cf19042cbcdb19f71bc35ab2"
integrity sha512-UKTiEJPkWcESPYJz3X5uKRYyOcJD+4nYph+KpfdPRnQJVrZfk0KJgdnaAWKfhsBBtAf/D58Az4AvCJEmWgIBAg==
dependencies:
tslib "^2.6.2"

"@azure/core-util@^1.1.0", "@azure/core-util@^1.3.0", "@azure/core-util@^1.6.1", "@azure/core-util@^1.8.1", "@azure/core-util@^1.9.0":
version "1.9.2"
resolved "https://registry.yarnpkg.com/@azure/core-util/-/core-util-1.9.2.tgz#1dc37dc5b0dae34c578be62cf98905ba7c0cafe7"
Expand Down

0 comments on commit d3ab92c

Please sign in to comment.