@tauri-apps/plugin-http 2.5.9 → 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/README.md CHANGED
@@ -62,7 +62,7 @@ Afterwards all the plugin's APIs are available through the JavaScript guest bind
62
62
  import { fetch } from '@tauri-apps/plugin-http'
63
63
  const response = await fetch('http://localhost:3003/users/2', {
64
64
  method: 'GET',
65
- timeout: 30
65
+ connectTimeout: 30
66
66
  })
67
67
  ```
68
68
 
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 proimse
111
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
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
- return core.invoke('plugin:http|fetch_cancel_body', { rid: responseRid });
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 proimse
109
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
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
- return invoke('plugin:http|fetch_cancel_body', { rid: responseRid });
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-http",
3
- "version": "2.5.9",
3
+ "version": "2.6.1",
4
4
  "license": "MIT OR Apache-2.0",
5
5
  "authors": [
6
6
  "Tauri Programme within The Commons Conservancy"