@exodus/headless 5.0.0-rc.27 → 5.0.0-rc.28
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/CHANGELOG.md +6 -0
- package/package.json +5 -4
- package/src/index.js +2 -0
- package/src/plugins/attach.js +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.0.0-rc.28](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@5.0.0-rc.27...@exodus/headless@5.0.0-rc.28) (2024-07-29)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **headless:** add timeout log for plugin methods ([#8044](https://github.com/ExodusMovement/exodus-hydra/issues/8044)) ([1fb051f](https://github.com/ExodusMovement/exodus-hydra/commit/1fb051fcb0478b7a3278efe8922339984fda0539))
|
|
11
|
+
|
|
6
12
|
## [5.0.0-rc.27](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@5.0.0-rc.26...@exodus/headless@5.0.0-rc.27) (2024-07-25)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/headless",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.28",
|
|
4
4
|
"description": "The platform-agnostic Exodus wallet SDK",
|
|
5
5
|
"author": "Exodus Movement, Inc.",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -70,7 +70,8 @@
|
|
|
70
70
|
"bip39": "^2.6.0",
|
|
71
71
|
"events": "^3.3.0",
|
|
72
72
|
"lodash": "npm:@exodus/lodash@^4.17.21-exodus.2",
|
|
73
|
-
"minimalistic-assert": "^1.0.1"
|
|
73
|
+
"minimalistic-assert": "^1.0.1",
|
|
74
|
+
"ms": "^2.1.3"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
77
|
"@exodus/ab-testing": "^7.5.1",
|
|
@@ -98,7 +99,7 @@
|
|
|
98
99
|
"@exodus/models": "^11.9.0",
|
|
99
100
|
"@exodus/nfts": "^9.3.3",
|
|
100
101
|
"@exodus/personal-notes": "^3.6.2",
|
|
101
|
-
"@exodus/referrals": "^8.
|
|
102
|
+
"@exodus/referrals": "^8.7.3",
|
|
102
103
|
"@exodus/solana-lib": "^2.0.0",
|
|
103
104
|
"@exodus/solana-meta": "^1.0.2",
|
|
104
105
|
"@exodus/storage-encrypted": "^1.4.1",
|
|
@@ -114,5 +115,5 @@
|
|
|
114
115
|
"msw": "^2.0.0",
|
|
115
116
|
"p-defer": "^4.0.0"
|
|
116
117
|
},
|
|
117
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "95f2c3ed980cac4564367a8b0b3cc7d0badbe1f1"
|
|
118
119
|
}
|
package/src/index.js
CHANGED
|
@@ -28,6 +28,7 @@ import transactionSigner from '@exodus/tx-signer'
|
|
|
28
28
|
import typeforce from '@exodus/typeforce'
|
|
29
29
|
import wallet from '@exodus/wallet'
|
|
30
30
|
import walletAccounts from '@exodus/wallet-accounts'
|
|
31
|
+
import ms from 'ms'
|
|
31
32
|
|
|
32
33
|
import createApi from './api'
|
|
33
34
|
import createDependencies from './dependencies'
|
|
@@ -156,6 +157,7 @@ const createExodus = (opts) => {
|
|
|
156
157
|
application,
|
|
157
158
|
plugins: ioc.getByType('plugin'),
|
|
158
159
|
logger: ioc.get('createLogger')('attachPlugins'),
|
|
160
|
+
pluginTimeout: config?.ioc?.pluginMethodsTimeout || ms('5s'),
|
|
159
161
|
})
|
|
160
162
|
|
|
161
163
|
return createApi({ ioc, port, config, debug, logger: ioc.get('createLogger')('createApi') })
|
package/src/plugins/attach.js
CHANGED
|
@@ -7,20 +7,24 @@ const LIFECYCLE_METHOD_TO_HOOK_NAME = Object.fromEntries(
|
|
|
7
7
|
])
|
|
8
8
|
)
|
|
9
9
|
|
|
10
|
-
const attachPlugins = ({ plugins, application, logger }) => {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
const attachPlugins = ({ plugins, application, logger, pluginTimeout }) => {
|
|
11
|
+
const lifecycleFuncWrapper = (fn, name) => {
|
|
12
|
+
const timeFn = async (...args) => {
|
|
13
|
+
const timeoutPid = setTimeout(() => {
|
|
14
|
+
logger.warn(`${name} reached time out of ${pluginTimeout}ms and is still running ...`)
|
|
15
|
+
}, pluginTimeout)
|
|
13
16
|
const start = Date.now()
|
|
14
17
|
try {
|
|
15
18
|
return await fn(...args)
|
|
16
19
|
} finally {
|
|
17
20
|
logger.debug(name, `${Date.now() - start}ms`)
|
|
21
|
+
clearTimeout(timeoutPid)
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
Object.defineProperty(
|
|
25
|
+
Object.defineProperty(timeFn, 'name', { value: name, writable: false })
|
|
22
26
|
|
|
23
|
-
return
|
|
27
|
+
return timeFn
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
Object.entries(plugins).forEach(([name, lifecycleMethods]) => {
|
|
@@ -29,7 +33,7 @@ const attachPlugins = ({ plugins, application, logger }) => {
|
|
|
29
33
|
for (const [lifecycleMethod, fn] of entries) {
|
|
30
34
|
const hookName = LIFECYCLE_METHOD_TO_HOOK_NAME[lifecycleMethod]
|
|
31
35
|
if (hookName) {
|
|
32
|
-
application.hook(hookName,
|
|
36
|
+
application.hook(hookName, lifecycleFuncWrapper(fn, `plugin ${name}.${lifecycleMethod}`))
|
|
33
37
|
} else {
|
|
34
38
|
logger.error(`plugin "${name}" declares unsupported lifecycle method "${lifecycleMethod}"`)
|
|
35
39
|
}
|