fix: satisfy custom widget architecture limit
This commit is contained in:
1 parent
657704340c
commit
48438fc003
1 file changed
+2
-15
@@ -86,7 +86,7 @@ async function performRequest(input: CustomWidgetHttpRequest): Promise<CustomWid
|
|||||||
}
|
}
|
||||||
if (error instanceof CustomWidgetDomainError) throw error;
|
if (error instanceof CustomWidgetDomainError) throw error;
|
||||||
input.logError?.({
|
input.logError?.({
|
||||||
origin: safeOrigin(input.baseUrl),
|
origin: URL.canParse(input.baseUrl) ? new URL(input.baseUrl).origin : "invalid",
|
||||||
method: input.method,
|
method: input.method,
|
||||||
errorName: "TransportError",
|
errorName: "TransportError",
|
||||||
});
|
});
|
||||||
@@ -176,7 +176,7 @@ async function performRequestWithinDeadline(
|
|||||||
if (lifecycleFailure) {
|
if (lifecycleFailure) {
|
||||||
const { error } = lifecycleFailure;
|
const { error } = lifecycleFailure;
|
||||||
if (error instanceof CustomWidgetDomainError) throw error;
|
if (error instanceof CustomWidgetDomainError) throw error;
|
||||||
if (isResponseTooLargeError(error)) {
|
if (error instanceof Error && "code" in error && error.code === RESPONSE_TOO_LARGE_ERROR_CODE) {
|
||||||
throw new CustomWidgetDomainError({
|
throw new CustomWidgetDomainError({
|
||||||
code: "PAYLOAD_TOO_LARGE",
|
code: "PAYLOAD_TOO_LARGE",
|
||||||
message: "Response exceeds the 1 MiB limit",
|
message: "Response exceeds the 1 MiB limit",
|
||||||
@@ -225,19 +225,6 @@ export function isCustomWidgetRequestTimeoutError(error: unknown, ...signals: re
|
|||||||
return code !== undefined && TIMEOUT_ERROR_CODES.has(code);
|
return code !== undefined && TIMEOUT_ERROR_CODES.has(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isResponseTooLargeError(error: unknown): boolean {
|
|
||||||
if (!(error instanceof Error)) return false;
|
|
||||||
return "code" in error && error.code === RESPONSE_TOO_LARGE_ERROR_CODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
function safeOrigin(value: string): string {
|
|
||||||
try {
|
|
||||||
return new URL(value).origin;
|
|
||||||
} catch {
|
|
||||||
return "invalid";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeResponseHeaders(values: Record<string, string | string[] | undefined>) {
|
function normalizeResponseHeaders(values: Record<string, string | string[] | undefined>) {
|
||||||
const headers = new Headers();
|
const headers = new Headers();
|
||||||
for (const [name, value] of Object.entries(values)) {
|
for (const [name, value] of Object.entries(values)) {
|
||||||
|
|||||||
Reference in new issue
Block a user