@tauri-apps/plugin-http 2.6.0 → 2.6.1
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.
- package/dist-js/index.cjs +8 -5
- package/dist-js/index.js +8 -5
- package/package.json +1 -1
package/dist-js/index.cjs
CHANGED
|
@@ -103,21 +103,24 @@ async function fetch(input, init) {
|
|
|
103
103
|
danger
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
|
-
const abort = () => core.invoke('plugin:http|fetch_cancel', { rid });
|
|
106
|
+
const abort = () => core.invoke('plugin:http|fetch_cancel', { rid }).catch(() => { });
|
|
107
107
|
// Optimistically check for abort signal
|
|
108
108
|
// and avoid doing any work after doing intial work on the Rust side
|
|
109
109
|
if (signal?.aborted) {
|
|
110
|
-
// we don't care about the result of this
|
|
111
|
-
|
|
112
|
-
abort();
|
|
110
|
+
// we don't care about the result of this promise
|
|
111
|
+
void abort();
|
|
113
112
|
throw new Error(ERROR_REQUEST_CANCELLED);
|
|
114
113
|
}
|
|
115
114
|
signal?.addEventListener('abort', () => void abort());
|
|
116
115
|
const { status, statusText, url, headers: responseHeaders, rid: responseRid } = await core.invoke('plugin:http|fetch_send', {
|
|
117
116
|
rid
|
|
118
117
|
});
|
|
118
|
+
let bodyDropped = false;
|
|
119
119
|
const dropBody = () => {
|
|
120
|
-
|
|
120
|
+
if (bodyDropped)
|
|
121
|
+
return Promise.resolve();
|
|
122
|
+
bodyDropped = true;
|
|
123
|
+
return core.invoke('plugin:http|fetch_cancel_body', { rid: responseRid }).catch(() => { });
|
|
121
124
|
};
|
|
122
125
|
const readChunk = async (controller) => {
|
|
123
126
|
let data;
|
package/dist-js/index.js
CHANGED
|
@@ -101,21 +101,24 @@ async function fetch(input, init) {
|
|
|
101
101
|
danger
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
|
-
const abort = () => invoke('plugin:http|fetch_cancel', { rid });
|
|
104
|
+
const abort = () => invoke('plugin:http|fetch_cancel', { rid }).catch(() => { });
|
|
105
105
|
// Optimistically check for abort signal
|
|
106
106
|
// and avoid doing any work after doing intial work on the Rust side
|
|
107
107
|
if (signal?.aborted) {
|
|
108
|
-
// we don't care about the result of this
|
|
109
|
-
|
|
110
|
-
abort();
|
|
108
|
+
// we don't care about the result of this promise
|
|
109
|
+
void abort();
|
|
111
110
|
throw new Error(ERROR_REQUEST_CANCELLED);
|
|
112
111
|
}
|
|
113
112
|
signal?.addEventListener('abort', () => void abort());
|
|
114
113
|
const { status, statusText, url, headers: responseHeaders, rid: responseRid } = await invoke('plugin:http|fetch_send', {
|
|
115
114
|
rid
|
|
116
115
|
});
|
|
116
|
+
let bodyDropped = false;
|
|
117
117
|
const dropBody = () => {
|
|
118
|
-
|
|
118
|
+
if (bodyDropped)
|
|
119
|
+
return Promise.resolve();
|
|
120
|
+
bodyDropped = true;
|
|
121
|
+
return invoke('plugin:http|fetch_cancel_body', { rid: responseRid }).catch(() => { });
|
|
119
122
|
};
|
|
120
123
|
const readChunk = async (controller) => {
|
|
121
124
|
let data;
|