@fluwa-tool/sdk 1.0.28 → 1.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -94,8 +94,13 @@ class FetchInterceptor {
|
|
|
94
94
|
try {
|
|
95
95
|
// Registrar que começou
|
|
96
96
|
await this.requestLogger.logStart(requestMetadata);
|
|
97
|
-
//
|
|
98
|
-
|
|
97
|
+
// NÃO verificar mock para requisições internas (evita loop infinito)
|
|
98
|
+
// Requisições internas (/api/requests, /api/scenarios/active) devem passar direto
|
|
99
|
+
let mockResponse = null;
|
|
100
|
+
if (!this.isFluwaInternalRequest(init)) {
|
|
101
|
+
// Só verificar mock para requisições do usuário
|
|
102
|
+
mockResponse = await this.mockResolver.resolve(method, url);
|
|
103
|
+
}
|
|
99
104
|
if (mockResponse) {
|
|
100
105
|
// Usar mock
|
|
101
106
|
requestMetadata.source = types_1.RequestSource.MOCK;
|
|
@@ -100,12 +100,33 @@ class XMLHttpRequestInterceptor {
|
|
|
100
100
|
requestMetadata.status = xhr.status;
|
|
101
101
|
// Tentar extrair response
|
|
102
102
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
// responseText só está disponível para responseType 'text' ou '' (padrão)
|
|
104
|
+
if (xhr.responseType === '' || xhr.responseType === 'text') {
|
|
105
|
+
if (xhr.responseText) {
|
|
106
|
+
requestMetadata.response = self.safeParseBody(xhr.responseText);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else if (xhr.response) {
|
|
110
|
+
// Para blob, arraybuffer, document, etc., usar xhr.response
|
|
111
|
+
if (typeof xhr.response === 'string') {
|
|
112
|
+
requestMetadata.response = self.safeParseBody(xhr.response);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Não consegue serializar blob/arraybuffer, apenas registra tipo
|
|
116
|
+
requestMetadata.response = `[${xhr.responseType}]`;
|
|
117
|
+
}
|
|
105
118
|
}
|
|
106
119
|
}
|
|
107
120
|
catch (e) {
|
|
108
|
-
|
|
121
|
+
// Em caso de erro, tenta responseText como fallback
|
|
122
|
+
try {
|
|
123
|
+
if (xhr.responseText) {
|
|
124
|
+
requestMetadata.response = xhr.responseText;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
requestMetadata.response = undefined;
|
|
129
|
+
}
|
|
109
130
|
}
|
|
110
131
|
const duration = Date.now() - (xhr._fluwaStartTime || 0);
|
|
111
132
|
requestMetadata.duration = duration;
|