Skip to content

fix: clean dist before build and retry throttled reader responses - #125

Merged
yeboster merged 4 commits into
mainfrom
fix/clean-dist-before-build
Aug 30, 2026
Merged

fix: clean dist before build and retry throttled reader responses#125
yeboster merged 4 commits into
mainfrom
fix/clean-dist-before-build

Conversation

@yeboster

Copy link
Copy Markdown
Contributor

Found while reviewing the whole SDK before cutting v7, and while running the React app's suites against a v7 tarball.

1. Stale files ship in the published package (release blocker)

build is build:cjs && build:esm, both plain tsc runs into an existing dist/. Nothing removes output for sources that no longer exist. A tarball packed from this tree today contains:

package/dist/transactions/helper.js      # deleted in #123
package/dist/esm/transactions/helper.js
package/dist/version.js                  # deleted in #124

prepublishOnly runs build, so a real npm publish of 7.0.0 would have shipped dead modules that reference ShardedClient methods #120 removed — and the ./dist/* exports pattern makes them importable. Fixed with a clean step inside build.

2. A throttled reader node reports as a missing contract

handleFetch resolves a body only on HTTP 200 and returns undefined for everything else, with no retry above the fetch itself. A 429 or 503 therefore reaches getContractFromRegistry as "no contract", which throws Contract not found.

Observed for real: running the app's Playwright suite (4 workers, live testnet) produced repeated Error: Contract not found from sdk.domainRepository.getAll() in /api/domains/recent and /api/domains/stats, while the same call from a single process succeeds (1313 domains). Two dns-records specs failed behind it.

429 and 5xx are now retried by the existing promiseRetry chain. 404 and other 4xx still fall through to undefined — that path is how getContractStateAvlValue reports a missing key, and it is unchanged.

3. ./transactions is not in the exports map

v7 adds privateKeyToAddress (the replacement for the app's partisia-blockchain-applications-crypto usage) and exports the four signing backends from src/transactions/index.ts, but the only way to reach them was the deep @metanames/sdk/dist/transactions. Added a ./transactions subpath.

Verification

  • yarn build then ls dist/transactions — no helper.js
  • yarn test — 269/269 green against live testnet
  • npx tsc --noEmit, npx eslint src — clean
  • App on a dev/sdk-v7 branch installed from a v7 tarball: tsc --noEmit clean, 766/766 vitest, next build green, 157/162 e2e (remaining failures are app-side color-contrast a11y, unrelated)

Three release-blocking issues found while reviewing v7 end to end.

`yarn build` wrote into whatever `dist/` was already there, so files deleted
from `src` survived in the published package: 7.0.0 packed with
`dist/transactions/helper.js` (deleted in #123) and `dist/version.js` (deleted
in #124), both reachable through the `./dist/*` exports pattern. `prepublishOnly`
runs `build`, so the fix is a clean step in `build` itself.

A reader node under load answers 429 or 503. `handleFetch` only resolves a body
on HTTP 200, so those answers arrived at callers as `undefined` and surfaced as
`Error: Contract not found` -- observed against the app's `/api/domains/recent`
and `/api/domains/stats` routes while running its end-to-end suite. Retry them.
404 still falls through to `undefined`, which is how a missing AVL value is
reported.

`privateKeyToAddress` and the signing backends had no exports entry, leaving
`@metanames/sdk/dist/transactions` as the only way in. Add `./transactions`.
@github-actions

Copy link
Copy Markdown

Total Coverage: 91.87%

Coverage Report
File Branch Funcs Lines Uncovered Lines
src
   actions.ts 100% 100% 100%
   index.ts 100% 100% 100%
   interface.ts 100% 100% 100%
   meta-names-sdk.ts 75% 75% 95.65% 22, 44, 45
   partisia-name-system.ts 58% 87.50% 84.07% 106, 114, 12, 139, 152, 160, 164, 169, 170, 171, 178, 180, 188, 189, 19, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 22, 220, 221, 222, 29, 33, 42, 49, 54, 55, 7, 78, 82
   version.ts 100% 100% 100%
src/actions
   domain.ts 64.29% 100% 100% 34, 43, 55, 70, 73
   record.ts 77.78% 100% 100% 13, 47
src/models
   domain.ts 100% 83.33% 95.95% 45, 46, 47
   index.ts 100% 100% 100%
src/models/helpers
   domain.ts 100% 100% 100%
src/providers
   config.ts 66.67% 100% 98.11% 40, 49, 50
   index.ts 100% 100% 100%
   secrets.ts 45.45% 62.50% 78.57% 19, 23, 24, 25, 26, 27, 29, 30, 44, 50, 51, 52, 53, 56, 57, 58, 59, 62, 63, 64, 65
src/providers/config
   mainnet.ts 100% 100% 100%
   testnet.ts 100% 100% 100%
src/repositories
   contract-repository.ts 76.92% 100% 98.28% 101, 111, 134, 135, 137, 138, 140, 141, 143, 144, 153, 169, 191, 207, 32, 44, 45, 55, 61
   domain-repository.ts 60% 100% 100% 102, 113, 117, 118, 133, 142, 150, 176, 220, 225, 240, 256, 262, 269, 34, 53, 54, 96, 98, 99
   index.ts 100% 75% 100%
   record-repository.ts 71.43% 100% 100% 24, 34, 50, 60
src/repositories/contracts
   meta-names-contract-repository.ts 84.62% 88.89% 86.14% 57, 58, 59, 60, 61, 62, 63, 64, 78, 79, 80, 81, 82, 83, 84, 94
src/repositories/helpers
   avl-client.ts 80% 77.78% 61.62% 16, 22, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 95
   client.ts 87.50% 100% 100% 43, 70
   contract.ts 75% 100% 92.45% 41, 42, 43, 44, 45, 50
   sharded-client.ts 66.67% 100% 100% 41, 52
src/transactions
   authentication.ts 100% 25% 38.79% 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 94, 95, 96, 97, 98, 99
   index.ts 46.15% 37.50% 85.38% 102, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 125, 16, 17, 18, 19, 69, 73, 82, 83, 84, 86, 86, 87, 88
src/validators
   base-validator.ts 100% 100% 100%
   domain-validator.ts 87.50% 100% 100% 29, 30, 31
   index.ts 100% 100% 100%
   record-validator.ts 100% 100% 100%
src/validators/idna
   index.ts 81.54% 100% 95.93% 108, 110, 110, 111, 118, 119, 120, 121, 122, 123, 124, 125, 136, 138, 139, 144, 151, 155, 168, 210, 46
   table.ts 100% 100% 100%
src/validators/records
   default-validator.ts 100% 100% 100%
   discord-validator.ts 100% 100% 100%
   email-validator.ts 100% 100% 100%
   main-validator.ts 100% 100% 100%
   price-validator.ts 100% 100% 100%
   regex-validator.ts 100% 100% 100%
   twitter-validator.ts 100% 100% 100%
   uri-validator.ts 100% 100% 100%
   wallet-validator.ts 100% 100% 100%
test
test/helpers
   config.ts 0% 100% 100% 7
   helper.ts 100% 60% 68% 25, 26, 27, 28, 29, 30, 31, 32, 35, 36, 37, 38, 39, 40, 41, 42
   index.ts 100% 100% 100%

6.3.1 shipped no exports map, so `@metanames/sdk/dist/models` and its
siblings resolved through plain file lookup. The exports map added in v7
turns those into `./dist/models.js`, which does not exist, and Node does
not fall back to a directory index. Consumers on those specifiers would
break on upgrade for no reason: each directory has an `index.js`, so the
entries point at it.

Claude-Session: https://claude.ai/code/session_01GceWCwGXu66D1xEBDxZWBb
@github-actions

Copy link
Copy Markdown

Total Coverage: 91.86%

Coverage Report
File Branch Funcs Lines Uncovered Lines
src
   actions.ts 100% 100% 100%
   index.ts 100% 100% 100%
   interface.ts 100% 100% 100%
   meta-names-sdk.ts 75% 75% 95.45% 20, 42, 43
   partisia-name-system.ts 58% 87.50% 84.07% 106, 114, 12, 139, 152, 160, 164, 169, 170, 171, 178, 180, 188, 189, 19, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 22, 220, 221, 222, 29, 33, 42, 49, 54, 55, 7, 78, 82
src/actions
   domain.ts 64.29% 100% 100% 34, 43, 55, 70, 73
   record.ts 77.78% 100% 100% 13, 47
src/models
   domain.ts 100% 83.33% 95.95% 45, 46, 47
   index.ts 100% 100% 100%
src/models/helpers
   domain.ts 100% 100% 100%
src/providers
   config.ts 66.67% 100% 98.11% 40, 49, 50
   index.ts 100% 100% 100%
   secrets.ts 45.45% 62.50% 78.57% 19, 23, 24, 25, 26, 27, 29, 30, 44, 50, 51, 52, 53, 56, 57, 58, 59, 62, 63, 64, 65
src/providers/config
   mainnet.ts 100% 100% 100%
   testnet.ts 100% 100% 100%
src/repositories
   contract-repository.ts 76.92% 100% 98.28% 101, 111, 134, 135, 137, 138, 140, 141, 143, 144, 153, 169, 191, 207, 32, 44, 45, 55, 61
   domain-repository.ts 60% 100% 100% 102, 113, 117, 118, 133, 142, 150, 176, 220, 225, 240, 256, 262, 269, 34, 53, 54, 96, 98, 99
   index.ts 100% 75% 100%
   record-repository.ts 71.43% 100% 100% 24, 34, 50, 60
src/repositories/contracts
   meta-names-contract-repository.ts 84.62% 88.89% 86.14% 57, 58, 59, 60, 61, 62, 63, 64, 78, 79, 80, 81, 82, 83, 84, 94
src/repositories/helpers
   avl-client.ts 80% 77.78% 61.62% 16, 22, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 95
   client.ts 87.50% 100% 100% 43, 70
   contract.ts 75% 100% 92.45% 41, 42, 43, 44, 45, 50
   sharded-client.ts 66.67% 100% 100% 41, 52
src/transactions
   authentication.ts 100% 25% 38.79% 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 94, 95, 96, 97, 98, 99
   index.ts 46.15% 37.50% 85.38% 102, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 125, 16, 17, 18, 19, 69, 73, 82, 83, 84, 86, 86, 87, 88
src/validators
   base-validator.ts 100% 100% 100%
   domain-validator.ts 87.50% 100% 100% 29, 30, 31
   index.ts 100% 100% 100%
   record-validator.ts 100% 100% 100%
src/validators/idna
   index.ts 81.54% 100% 95.93% 108, 110, 110, 111, 118, 119, 120, 121, 122, 123, 124, 125, 136, 138, 139, 144, 151, 155, 168, 210, 46
   table.ts 100% 100% 100%
src/validators/records
   default-validator.ts 100% 100% 100%
   discord-validator.ts 100% 100% 100%
   email-validator.ts 100% 100% 100%
   main-validator.ts 100% 100% 100%
   price-validator.ts 100% 100% 100%
   regex-validator.ts 100% 100% 100%
   twitter-validator.ts 100% 100% 100%
   uri-validator.ts 100% 100% 100%
   wallet-validator.ts 100% 100% 100%
test
test/helpers
   config.ts 0% 100% 100% 7
   helper.ts 100% 60% 68% 25, 26, 27, 28, 29, 30, 31, 32, 35, 36, 37, 38, 39, 40, 41, 42
   index.ts 100% 100% 100%

Working notes committed by accident in the previous commit. #125 squash
merges, so main never carries them.

Claude-Session: https://claude.ai/code/session_01GceWCwGXu66D1xEBDxZWBb
@github-actions

Copy link
Copy Markdown

Total Coverage: 91.86%

Coverage Report
File Branch Funcs Lines Uncovered Lines
src
   actions.ts 100% 100% 100%
   index.ts 100% 100% 100%
   interface.ts 100% 100% 100%
   meta-names-sdk.ts 75% 75% 95.45% 20, 42, 43
   partisia-name-system.ts 58% 87.50% 84.07% 106, 114, 12, 139, 152, 160, 164, 169, 170, 171, 178, 180, 188, 189, 19, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 22, 220, 221, 222, 29, 33, 42, 49, 54, 55, 7, 78, 82
src/actions
   domain.ts 64.29% 100% 100% 34, 43, 55, 70, 73
   record.ts 77.78% 100% 100% 13, 47
src/models
   domain.ts 100% 83.33% 95.95% 45, 46, 47
   index.ts 100% 100% 100%
src/models/helpers
   domain.ts 100% 100% 100%
src/providers
   config.ts 66.67% 100% 98.11% 40, 49, 50
   index.ts 100% 100% 100%
   secrets.ts 45.45% 62.50% 78.57% 19, 23, 24, 25, 26, 27, 29, 30, 44, 50, 51, 52, 53, 56, 57, 58, 59, 62, 63, 64, 65
src/providers/config
   mainnet.ts 100% 100% 100%
   testnet.ts 100% 100% 100%
src/repositories
   contract-repository.ts 76.92% 100% 98.28% 101, 111, 134, 135, 137, 138, 140, 141, 143, 144, 153, 169, 191, 207, 32, 44, 45, 55, 61
   domain-repository.ts 60% 100% 100% 102, 113, 117, 118, 133, 142, 150, 176, 220, 225, 240, 256, 262, 269, 34, 53, 54, 96, 98, 99
   index.ts 100% 75% 100%
   record-repository.ts 71.43% 100% 100% 24, 34, 50, 60
src/repositories/contracts
   meta-names-contract-repository.ts 84.62% 88.89% 86.14% 57, 58, 59, 60, 61, 62, 63, 64, 78, 79, 80, 81, 82, 83, 84, 94
src/repositories/helpers
   avl-client.ts 80% 77.78% 61.62% 16, 22, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 95
   client.ts 87.50% 100% 100% 43, 70
   contract.ts 75% 100% 92.45% 41, 42, 43, 44, 45, 50
   sharded-client.ts 66.67% 100% 100% 41, 52
src/transactions
   authentication.ts 100% 25% 38.79% 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 94, 95, 96, 97, 98, 99
   index.ts 46.15% 37.50% 85.38% 102, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 125, 16, 17, 18, 19, 69, 73, 82, 83, 84, 86, 86, 87, 88
src/validators
   base-validator.ts 100% 100% 100%
   domain-validator.ts 87.50% 100% 100% 29, 30, 31
   index.ts 100% 100% 100%
   record-validator.ts 100% 100% 100%
src/validators/idna
   index.ts 81.54% 100% 95.93% 108, 110, 110, 111, 118, 119, 120, 121, 122, 123, 124, 125, 136, 138, 139, 144, 151, 155, 168, 210, 46
   table.ts 100% 100% 100%
src/validators/records
   default-validator.ts 100% 100% 100%
   discord-validator.ts 100% 100% 100%
   email-validator.ts 100% 100% 100%
   main-validator.ts 100% 100% 100%
   price-validator.ts 100% 100% 100%
   regex-validator.ts 100% 100% 100%
   twitter-validator.ts 100% 100% 100%
   uri-validator.ts 100% 100% 100%
   wallet-validator.ts 100% 100% 100%
test
test/helpers
   config.ts 0% 100% 100% 7
   helper.ts 100% 60% 68% 25, 26, 27, 28, 29, 30, 31, 32, 35, 36, 37, 38, 39, 40, 41, 42
   index.ts 100% 100% 100%

`./dist/*` was carried over so consumers importing the build output kept
working. That advertises the build layout as API: the paths hard-code the
CJS tree, and nothing outside it can move without breaking someone. v7 is
the major to stop. The named subpaths cover every use.

Claude-Session: https://claude.ai/code/session_01GceWCwGXu66D1xEBDxZWBb
@github-actions

Copy link
Copy Markdown

Total Coverage: 91.86%

Coverage Report
File Branch Funcs Lines Uncovered Lines
src
   actions.ts 100% 100% 100%
   index.ts 100% 100% 100%
   interface.ts 100% 100% 100%
   meta-names-sdk.ts 75% 75% 95.45% 20, 42, 43
   partisia-name-system.ts 58% 87.50% 84.07% 106, 114, 12, 139, 152, 160, 164, 169, 170, 171, 178, 180, 188, 189, 19, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 22, 220, 221, 222, 29, 33, 42, 49, 54, 55, 7, 78, 82
src/actions
   domain.ts 64.29% 100% 100% 34, 43, 55, 70, 73
   record.ts 77.78% 100% 100% 13, 47
src/models
   domain.ts 100% 83.33% 95.95% 45, 46, 47
   index.ts 100% 100% 100%
src/models/helpers
   domain.ts 100% 100% 100%
src/providers
   config.ts 66.67% 100% 98.11% 40, 49, 50
   index.ts 100% 100% 100%
   secrets.ts 45.45% 62.50% 78.57% 19, 23, 24, 25, 26, 27, 29, 30, 44, 50, 51, 52, 53, 56, 57, 58, 59, 62, 63, 64, 65
src/providers/config
   mainnet.ts 100% 100% 100%
   testnet.ts 100% 100% 100%
src/repositories
   contract-repository.ts 76.92% 100% 98.28% 101, 111, 134, 135, 137, 138, 140, 141, 143, 144, 153, 169, 191, 207, 32, 44, 45, 55, 61
   domain-repository.ts 60% 100% 100% 102, 113, 117, 118, 133, 142, 150, 176, 220, 225, 240, 256, 262, 269, 34, 53, 54, 96, 98, 99
   index.ts 100% 75% 100%
   record-repository.ts 71.43% 100% 100% 24, 34, 50, 60
src/repositories/contracts
   meta-names-contract-repository.ts 84.62% 88.89% 86.14% 57, 58, 59, 60, 61, 62, 63, 64, 78, 79, 80, 81, 82, 83, 84, 94
src/repositories/helpers
   avl-client.ts 80% 77.78% 61.62% 16, 22, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 95
   client.ts 87.50% 100% 100% 43, 70
   contract.ts 75% 100% 92.45% 41, 42, 43, 44, 45, 50
   sharded-client.ts 66.67% 100% 100% 41, 52
src/transactions
   authentication.ts 100% 25% 38.79% 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 94, 95, 96, 97, 98, 99
   index.ts 46.15% 37.50% 85.38% 102, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 125, 16, 17, 18, 19, 69, 73, 82, 83, 84, 86, 86, 87, 88
src/validators
   base-validator.ts 100% 100% 100%
   domain-validator.ts 87.50% 100% 100% 29, 30, 31
   index.ts 100% 100% 100%
   record-validator.ts 100% 100% 100%
src/validators/idna
   index.ts 81.54% 100% 95.93% 108, 110, 110, 111, 118, 119, 120, 121, 122, 123, 124, 125, 136, 138, 139, 144, 151, 155, 168, 210, 46
   table.ts 100% 100% 100%
src/validators/records
   default-validator.ts 100% 100% 100%
   discord-validator.ts 100% 100% 100%
   email-validator.ts 100% 100% 100%
   main-validator.ts 100% 100% 100%
   price-validator.ts 100% 100% 100%
   regex-validator.ts 100% 100% 100%
   twitter-validator.ts 100% 100% 100%
   uri-validator.ts 100% 100% 100%
   wallet-validator.ts 100% 100% 100%
test
test/helpers
   config.ts 0% 100% 100% 7
   helper.ts 100% 60% 68% 25, 26, 27, 28, 29, 30, 31, 32, 35, 36, 37, 38, 39, 40, 41, 42
   index.ts 100% 100% 100%

@yeboster
yeboster merged commit fa71926 into main Aug 30, 2026
8 checks passed
@yeboster
yeboster deleted the fix/clean-dist-before-build branch August 30, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant