Skip to content

Commit 005569a

Browse files
authored
fix(apisix-standalone): log when requests fail (#359)
1 parent c1b5759 commit 005569a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

libs/backend-apisix-standalone/src/operator.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ export class Operator extends ADCSDK.backend.BackendEventSource {
120120
ADCSDK.BackendSyncResult,
121121
ObservableInput<ADCSDK.BackendSyncResult>
122122
>((error: Error | AxiosError) => {
123+
// Log the error response when error
124+
if (axios.isAxiosError(error) && error.response)
125+
logger(this.debugLogEvent(error.response));
126+
123127
if (opts.exitOnFailure) {
124128
if (axios.isAxiosError(error) && error.response)
125129
return throwError(
@@ -144,9 +148,11 @@ export class Operator extends ADCSDK.backend.BackendEventSource {
144148
server,
145149
} satisfies ADCSDK.BackendSyncResult);
146150
}),
147-
tap(() => {
148-
configCache.set(this.opts.cacheKey, toADC(newConfig));
149-
rawConfigCache.set(this.opts.cacheKey, newConfig);
151+
tap((res) => {
152+
if (res.success) {
153+
configCache.set(this.opts.cacheKey, toADC(newConfig));
154+
rawConfigCache.set(this.opts.cacheKey, newConfig);
155+
}
150156
logger(taskStateEvent('TASK_DONE'));
151157
}),
152158
),

0 commit comments

Comments
 (0)