@ar.io/sdk 3.11.0-alpha.2 → 3.11.0-alpha.4
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/bundles/web.bundle.min.js +64 -64
- package/lib/cjs/common/wayfinder/wayfinder.js +1 -1
- package/lib/cjs/utils/ao.js +37 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/wayfinder/wayfinder.js +1 -1
- package/lib/esm/utils/ao.js +37 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/common/wayfinder/wayfinder.d.ts +2 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -69,7 +69,7 @@ const createWayfinderClient = ({ httpClient, resolveUrl, }) => {
|
|
|
69
69
|
// support direct calls: fetch('ar://…', options)
|
|
70
70
|
// axios() or got()
|
|
71
71
|
apply: (_target, _thisArg, argArray) => wayfinderRedirect(httpClient, argArray),
|
|
72
|
-
// support http clients that use
|
|
72
|
+
// support http clients that use functions like `got.get`, `got.post`, `axios.get`, etc. while still using the wayfinder redirect function
|
|
73
73
|
get: (target, prop, receiver) => {
|
|
74
74
|
const value = Reflect.get(target, prop, receiver);
|
|
75
75
|
if (typeof value === 'function') {
|
package/lib/cjs/utils/ao.js
CHANGED
|
@@ -54,6 +54,43 @@ async function spawnANT({ signer, module = constants_js_1.AOS_MODULE_ID, ao = (0
|
|
|
54
54
|
},
|
|
55
55
|
],
|
|
56
56
|
});
|
|
57
|
+
let bootRes;
|
|
58
|
+
let attempts = 0;
|
|
59
|
+
while (attempts < 5 && bootRes === undefined) {
|
|
60
|
+
try {
|
|
61
|
+
bootRes = await ao.result({
|
|
62
|
+
process: processId,
|
|
63
|
+
message: processId,
|
|
64
|
+
});
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
logger.debug('Retrying ANT boot result fetch', {
|
|
69
|
+
processId,
|
|
70
|
+
module,
|
|
71
|
+
scheduler,
|
|
72
|
+
attempts,
|
|
73
|
+
error,
|
|
74
|
+
});
|
|
75
|
+
attempts++;
|
|
76
|
+
await new Promise((resolve) => setTimeout(resolve, 1000 * attempts ** 2));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (bootRes === undefined ||
|
|
80
|
+
bootRes.Messages.find((m) => m.Tags.find((t) => t.value === 'Invalid-Boot-Notice'))) {
|
|
81
|
+
if (bootRes === undefined) {
|
|
82
|
+
throw new Error('Failed to get boot result');
|
|
83
|
+
}
|
|
84
|
+
const bootError = errorMessageFromOutput(bootRes);
|
|
85
|
+
logger.error('ANT failed to boot correctly', {
|
|
86
|
+
processId,
|
|
87
|
+
module,
|
|
88
|
+
scheduler,
|
|
89
|
+
bootRes,
|
|
90
|
+
bootError,
|
|
91
|
+
});
|
|
92
|
+
throw new Error(`ANT failed to boot correctly: ${bootError}`);
|
|
93
|
+
}
|
|
57
94
|
logger.debug(`Spawned ANT`, {
|
|
58
95
|
processId,
|
|
59
96
|
module,
|
package/lib/cjs/version.js
CHANGED
|
@@ -65,7 +65,7 @@ export const createWayfinderClient = ({ httpClient, resolveUrl, }) => {
|
|
|
65
65
|
// support direct calls: fetch('ar://…', options)
|
|
66
66
|
// axios() or got()
|
|
67
67
|
apply: (_target, _thisArg, argArray) => wayfinderRedirect(httpClient, argArray),
|
|
68
|
-
// support http clients that use
|
|
68
|
+
// support http clients that use functions like `got.get`, `got.post`, `axios.get`, etc. while still using the wayfinder redirect function
|
|
69
69
|
get: (target, prop, receiver) => {
|
|
70
70
|
const value = Reflect.get(target, prop, receiver);
|
|
71
71
|
if (typeof value === 'function') {
|
package/lib/esm/utils/ao.js
CHANGED
|
@@ -43,6 +43,43 @@ export async function spawnANT({ signer, module = AOS_MODULE_ID, ao = connect(),
|
|
|
43
43
|
},
|
|
44
44
|
],
|
|
45
45
|
});
|
|
46
|
+
let bootRes;
|
|
47
|
+
let attempts = 0;
|
|
48
|
+
while (attempts < 5 && bootRes === undefined) {
|
|
49
|
+
try {
|
|
50
|
+
bootRes = await ao.result({
|
|
51
|
+
process: processId,
|
|
52
|
+
message: processId,
|
|
53
|
+
});
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
logger.debug('Retrying ANT boot result fetch', {
|
|
58
|
+
processId,
|
|
59
|
+
module,
|
|
60
|
+
scheduler,
|
|
61
|
+
attempts,
|
|
62
|
+
error,
|
|
63
|
+
});
|
|
64
|
+
attempts++;
|
|
65
|
+
await new Promise((resolve) => setTimeout(resolve, 1000 * attempts ** 2));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (bootRes === undefined ||
|
|
69
|
+
bootRes.Messages.find((m) => m.Tags.find((t) => t.value === 'Invalid-Boot-Notice'))) {
|
|
70
|
+
if (bootRes === undefined) {
|
|
71
|
+
throw new Error('Failed to get boot result');
|
|
72
|
+
}
|
|
73
|
+
const bootError = errorMessageFromOutput(bootRes);
|
|
74
|
+
logger.error('ANT failed to boot correctly', {
|
|
75
|
+
processId,
|
|
76
|
+
module,
|
|
77
|
+
scheduler,
|
|
78
|
+
bootRes,
|
|
79
|
+
bootError,
|
|
80
|
+
});
|
|
81
|
+
throw new Error(`ANT failed to boot correctly: ${bootError}`);
|
|
82
|
+
}
|
|
46
83
|
logger.debug(`Spawned ANT`, {
|
|
47
84
|
processId,
|
|
48
85
|
module,
|
package/lib/esm/version.js
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { WayfinderRouter } from '../../types/wayfinder.js';
|
|
17
|
-
type
|
|
17
|
+
type HttpClientArgs = [string | URL, ...unknown[]];
|
|
18
|
+
type HttpClientFunction = (...args: HttpClientArgs) => unknown;
|
|
18
19
|
type WayfinderHttpClient<T extends HttpClientFunction> = T;
|
|
19
20
|
export declare const arnsRegex: RegExp;
|
|
20
21
|
export declare const txIdRegex: RegExp;
|
package/lib/types/version.d.ts
CHANGED