Skip to content

Commit 8a498fe

Browse files
authored
fix: remove client-side timeout from http rpc calls (#3178)
Do not set up a client-side timeout, instead rely on the server-side version. The global timeout is still respected, users can use an AbortSignal to do timeouts on a per-call basis if desired. Also brings refs API in line with go-IPFS - timeouts are recorded in the `.err` prop of the output instead of the whole API call throwing a `TimeoutError` fixes: #3161
1 parent 025914e commit 8a498fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+12
-100
lines changed

src/add-all.js

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ module.exports = configure((api) => {
4343
...options,
4444
progress: Boolean(progressFn)
4545
}),
46-
timeout: options.timeout,
4746
onUploadProgress,
4847
signal,
4948
headers,

src/bitswap/stat.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = configure(api => {
1616
async function stat (options = {}) {
1717
const res = await api.post('bitswap/stat', {
1818
searchParams: toUrlSearchParams(options),
19-
timeout: options.timeout,
2019
signal: options.signal,
2120
headers: options.headers
2221
})

src/bitswap/unwant.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function unwant (cid, options = {}) {
1616
const res = await api.post('bitswap/unwant', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
arg: cid.toString(),

src/bitswap/wantlist-for-peer.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function wantlistForPeer (peerId, options = {}) {
1717
const res = await (await api.post('bitswap/wantlist', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams({
2120
...options,

src/bitswap/wantlist.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function wantlist (options = {}) {
1717
const res = await (await api.post('bitswap/wantlist', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams(options),
2120
headers: options.headers

src/block/get.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function get (cid, options = {}) {
1616
const res = await api.post('block/get', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
arg: cid.toString(),

src/block/put.js

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ module.exports = configure(api => {
2424
let res
2525
try {
2626
const response = await api.post('block/put', {
27-
timeout: options.timeout,
2827
signal: signal,
2928
searchParams: toUrlSearchParams(options),
3029
...(

src/block/rm.js

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module.exports = configure(api => {
2020
}
2121

2222
const res = await api.post('block/rm', {
23-
timeout: options.timeout,
2423
signal: options.signal,
2524
searchParams: toUrlSearchParams({
2625
arg: cid.map(cid => cid.toString()),

src/block/stat.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function stat (cid, options = {}) {
1717
const res = await api.post('block/stat', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams({
2120
arg: cid.toString(),

src/bootstrap/add.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function add (addr, options = {}) {
1717
const res = await api.post('bootstrap/add', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams({
2120
arg: addr,

src/bootstrap/clear.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function clear (options = {}) {
1717
const res = await api.post('bootstrap/rm', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams({
2120
...options,

src/bootstrap/list.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function list (options = {}) {
1717
const res = await api.post('bootstrap/list', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams(options),
2120
headers: options.headers

src/bootstrap/reset.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function reset (options = {}) {
1717
const res = await api.post('bootstrap/add', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams({
2120
...options,

src/bootstrap/rm.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function rm (addr, options = {}) {
1717
const res = await api.post('bootstrap/rm', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams({
2120
arg: addr,

src/cat.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function * cat (path, options = {}) {
1616
const res = await api.post('cat', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
arg: path.toString(),

src/commands.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
const commands = async (options = {}) => {
1616
const res = await api.post('commands', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams(options),
2019
headers: options.headers

src/config/get.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module.exports = configure(api => {
1818
}
1919

2020
const res = await api.post('config', {
21-
timeout: options.timeout,
2221
signal: options.signal,
2322
searchParams: toUrlSearchParams({
2423
arg: key,

src/config/getAll.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
const getAll = async (options = {}) => {
1616
const res = await api.post('config/show', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
...options

src/config/profiles/apply.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function apply (profile, options = {}) {
1616
const res = await api.post('config/profile/apply', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
arg: profile,

src/config/profiles/list.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function list (options = {}) {
1717
const res = await api.post('config/profile/list', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams(options),
2120
headers: options.headers

src/config/replace.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ module.exports = configure(api => {
2222
const signal = abortSignal(controller.signal, options.signal)
2323

2424
const res = await api.post('config/replace', {
25-
timeout: options.timeout,
2625
signal,
2726
searchParams: toUrlSearchParams(options),
2827
...(

src/config/set.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ module.exports = configure(api => {
2323
}
2424

2525
const res = await api.post('config', {
26-
timeout: options.timeout,
2726
signal: options.signal,
2827
searchParams: toUrlSearchParams(params),
2928
headers: options.headers

src/dag/export.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function * dagExport (root, options = {}) {
1616
const res = await api.post('dag/export', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
arg: root.toString()

src/dag/import.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ module.exports = configure(api => {
2222
const { headers, body } = await multipartRequest(source, controller, options.headers)
2323

2424
const res = await api.post('dag/import', {
25-
timeout: options.timeout,
2625
signal,
2726
headers,
2827
body,

src/dag/resolve.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
const resolve = async (ipfsPath, options = {}) => {
1717
const res = await api.post('dag/resolve', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams({
2120
arg: `${ipfsPath}${options.path ? `/${options.path}`.replace(/\/[/]+/g, '/') : ''}`,

src/dht/find-peer.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = configure(api => {
1616
*/
1717
async function findPeer (peerId, options = {}) {
1818
const res = await api.post('dht/findpeer', {
19-
timeout: options.timeout,
2019
signal: options.signal,
2120
searchParams: toUrlSearchParams({
2221
arg: peerId,

src/dht/find-provs.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = configure(api => {
1616
*/
1717
async function * findProvs (cid, options = {}) {
1818
const res = await api.post('dht/findprovs', {
19-
timeout: options.timeout,
2019
signal: options.signal,
2120
searchParams: toUrlSearchParams({
2221
arg: cid.toString(),

src/dht/get.js

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ module.exports = configure(api => {
1717
*/
1818
async function get (key, options = {}) {
1919
const res = await api.post('dht/get', {
20-
timeout: options.timeout,
2120
signal: options.signal,
2221
searchParams: toUrlSearchParams({
2322
arg: key instanceof Uint8Array ? uint8ArrayToString(key) : key,

src/dht/provide.js

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module.exports = configure(api => {
2020
const cidArr = Array.isArray(cids) ? cids : [cids]
2121

2222
const res = await api.post('dht/provide', {
23-
timeout: options.timeout,
2423
signal: options.signal,
2524
searchParams: toUrlSearchParams({
2625
arg: cidArr.map(cid => cid.toString()),

src/dht/put.js

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ module.exports = configure(api => {
2424
const signal = abortSignal(controller.signal, options.signal)
2525

2626
const res = await api.post('dht/put', {
27-
timeout: options.timeout,
2827
signal,
2928
searchParams: toUrlSearchParams({
3029
arg: uint8ArrayToString(key),

src/dht/query.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = configure(api => {
1616
*/
1717
async function * query (peerId, options = {}) {
1818
const res = await api.post('dht/query', {
19-
timeout: options.timeout,
2019
signal: options.signal,
2120
searchParams: toUrlSearchParams({
2221
arg: peerId.toString(),

src/diag/cmds.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function cmds (options = {}) {
1616
const res = await api.post('diag/cmds', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams(options),
2019
headers: options.headers

src/diag/net.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function net (options = {}) {
1616
const res = await api.post('diag/net', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams(options),
2019
headers: options.headers

src/diag/sys.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function sys (options = {}) {
1616
const res = await api.post('diag/sys', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams(options),
2019
headers: options.headers

src/dns.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
const dns = async (domain, options = {}) => {
1616
const res = await api.post('dns', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
arg: domain,

src/files/chmod.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function chmod (path, mode, options = {}) {
1616
const res = await api.post('files/chmod', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
arg: path,

src/files/cp.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module.exports = configure(api => {
1818
const sourceArr = Array.isArray(sources) ? sources : [sources]
1919

2020
const res = await api.post('files/cp', {
21-
timeout: options.timeout,
2221
signal: options.signal,
2322
searchParams: toUrlSearchParams({
2423
arg: sourceArr.concat(destination).map(src => src instanceof CID ? `/ipfs/${src}` : src),

src/files/flush.js

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module.exports = configure(api => {
1919
}
2020

2121
const res = await api.post('files/flush', {
22-
timeout: options.timeout,
2322
signal: options.signal,
2423
searchParams: toUrlSearchParams({
2524
arg: path,

src/files/ls.js

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module.exports = configure(api => {
1919
}
2020

2121
const res = await api.post('files/ls', {
22-
timeout: options.timeout,
2322
signal: options.signal,
2423
searchParams: toUrlSearchParams({
2524
arg: path instanceof CID ? `/ipfs/${path}` : path,

src/files/mkdir.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function mkdir (path, options = {}) {
1616
const res = await api.post('files/mkdir', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
arg: path,

src/files/mv.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module.exports = configure(api => {
1818
}
1919

2020
const res = await api.post('files/mv', {
21-
timeout: options.timeout,
2221
signal: options.signal,
2322
searchParams: toUrlSearchParams({
2423
arg: sources.concat(destination),

src/files/read.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = configure(api => {
1616
*/
1717
async function * read (path, options = {}) {
1818
const res = await api.post('files/read', {
19-
timeout: options.timeout,
2019
signal: options.signal,
2120
searchParams: toUrlSearchParams({
2221
arg: path,

src/files/rm.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function rm (path, options = {}) {
1616
const res = await api.post('files/rm', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
arg: path,

src/files/stat.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ module.exports = configure(api => {
2323
options = options || {}
2424

2525
const res = await api.post('files/stat', {
26-
timeout: options.timeout,
2726
signal: options.signal,
2827
searchParams: toUrlSearchParams({
2928
arg: path,

src/files/touch.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = configure(api => {
1414
*/
1515
async function touch (path, options = {}) {
1616
const res = await api.post('files/touch', {
17-
timeout: options.timeout,
1817
signal: options.signal,
1918
searchParams: toUrlSearchParams({
2019
arg: path,

src/files/write.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ module.exports = configure(api => {
2323
const signal = abortSignal(controller.signal, options.signal)
2424

2525
const res = await api.post('files/write', {
26-
timeout: options.timeout,
2726
signal,
2827
searchParams: toUrlSearchParams({
2928
arg: path,

src/get.js

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ module.exports = configure(api => {
2626
}
2727

2828
const res = await api.post('get', {
29-
timeout: options.timeout,
3029
signal: options.signal,
3130
searchParams: toUrlSearchParams(opts),
3231
headers: options.headers

src/id.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = configure(api => {
1616
*/
1717
async function id (options = {}) {
1818
const res = await api.post('id', {
19-
timeout: options.timeout,
2019
signal: options.signal,
2120
searchParams: toUrlSearchParams({
2221
arg: options.peerId ? options.peerId.toString() : undefined,

src/key/gen.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function gen (name, options = { type: 'rsa', size: 2048 }) {
1717
const res = await api.post('key/gen', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams({
2120
arg: name,

src/key/import.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = configure(api => {
1515
*/
1616
async function importKey (name, pem, password, options = {}) {
1717
const res = await api.post('key/import', {
18-
timeout: options.timeout,
1918
signal: options.signal,
2019
searchParams: toUrlSearchParams({
2120
arg: name,

0 commit comments

Comments
 (0)