fix remote client throwing unneccesary errors

This commit is contained in:
Percs 2024-04-20 11:42:03 -05:00
parent 3538b10630
commit 6385f6ad22

View file

@ -10,10 +10,10 @@ export function registerRemoteListener(channel: ServiceWorker) {
let response: any = await findSwitcher().active?.request(new URL(remote), method, body, headers, undefined)!.catch((err) => {
let error = { id: data.id, type: "error", error: err}
console.log(error)
console.error(err)
channel.postMessage(error);
return;
});
if (response) {
let transferred: any = [];
if (response.body instanceof ArrayBuffer || response.body instanceof Blob || response.body instanceof ReadableStream) {
transferred.push(response.body);
@ -22,6 +22,7 @@ export function registerRemoteListener(channel: ServiceWorker) {
response.type = "response";
channel.postMessage(response, transferred);
}
}
});
}