Skip to content

refactor(data-common): PGlite init-retry helper follow-ups from #205 review - #358

Open
sharonyajain wants to merge 3 commits into
mainfrom
fix/pglite-init-review-followup
Open

refactor(data-common): PGlite init-retry helper follow-ups from #205 review#358
sharonyajain wants to merge 3 commits into
mainfrom
fix/pglite-init-review-followup

Conversation

@sharonyajain

@sharonyajain sharonyajain commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #205 addressing @sarayev's three review comments based on improvement on the shared PGlite init-retry helper (data-common). No behavior change for the happy path or the recovery path shipped in #205 — this is polish + hardening.

1. Narrow the WASM-trap classifier (isPgliteUnreachableTrap)

Previously matched the bare word unreachable anywhere in the message/stack, which could misclassify an unrelated probe failure (an assertUnreachable helper, an "unreachable host" message) as a retryable trap. Now matches specific signatures only: RuntimeError: unreachable, wasm trap: unreachable, and the Emscripten Aborted() form.

2. Uniform cleanup in initializePgliteWithRetry

Retryability is now classified before consulting the attempt budget. A non-retryable error is always rethrown untouched (we never close an instance we didn't diagnose as a dead WASM trap), and this fixes the maxAttempts === 1 edge that previously closed the instance on any failure without classifying it.

3. Mark the init-retry exports @internal

initializePgliteWithRetry, isPgliteUnreachableTrap, PgliteLike, and PgliteInitRetryOptions exist only so the two engine packages can share the helper — they were needlessly part of data-common's public API. Marked @internal (and documented the PgliteLike methods); API.md regenerated to match.

Tests

  • Positive coverage for each trap signature (RuntimeError: unreachable, wasm trap:, Aborted()), including stack-only and cause-chain paths.
  • New negative test: a bare unreachable without a trap signature is not retried.
  • New maxAttempts=1 regressions: a non-retryable error does not close the instance; a trap still closes it and does not recreate.

…elper

- Narrow the WASM-trap classifier to specific signatures (RuntimeError:
  unreachable, wasm trap: unreachable, Emscripten Aborted()) instead of the
  bare word 'unreachable', so an unrelated probe failure that merely contains
  the word (assertUnreachable helpers, 'unreachable host') is not retried.
- Classify retryability before consulting the attempt budget in
  initializePgliteWithRetry, making instance cleanup uniform and fixing the
  maxAttempts=1 edge that closed on any failure without classifying.
- Mark the four init-retry exports @internal (shared only across engine
  packages) and document the PgliteLike methods; regenerate API.md.
- Update/extend tests: trap-signature positives, a bare-word negative, and
  maxAttempts=1 cleanup regressions.
@sharonyajain
sharonyajain requested a review from a team as a code owner August 13, 2026 15:30
@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 079bc35

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@aws-blocks/data-common Patch
@aws-blocks/blocks Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sharonyajain sharonyajain added the improvement Improvement to an existing feature label Aug 13, 2026

@ikenyal ikenyal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the classifier narrowing, the retry-budget ordering, and the generated API report. The new ordering correctly preserves a non-retryable instance when maxAttempts is 1 while still closing a diagnosed trap before giving up. The focused PGlite helper tests cover message, stack, cause-chain, negative, and exhausted-budget cases; I also ran all 18 of those tests locally. No blocking issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement to an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants