test(mobile): cover the AbortSignal polyfill (CODE-478) - #326
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
apps/mobile/src/polyfills.ts(CODE-462) is what lets the mobile client open a socket at all, and it had no test. This addsapps/mobile/src/__tests__/polyfills.test.ts— four cases in the app's existing vitest project, no production code touched.The module patches at import time behind
typeof AbortSignal.prototype.throwIfAborted !== "function", with no exported installer, so each case hands it a runtime without the API (deletethrowIfAborted+reasonoff the prototype) and re-runs it throughvi.resetModules()+ dynamicimport().afterEachputs all three patched globals back,AbortController.prototype.abortincluded.Cases:
throwIfAbortedis installed when the runtime lacks it, and a live signal does not throw.reasonround-trip —abort(reason)→signal.reason→throwIfAborted()rethrows the same value by identity, with a non-Errorreason so a future narrowing would fail here. RN 0.86 discards the argument toabort(reason)entirely, andConnectionControllerre-throwssignal.reasonwhen a run is superseded, so the symbol-recording wrapper is the only thing keeping that value alive on device.abort()with no argument yields afoxtsAbortError, from bothsignal.reasonand the throw.throwIfAborted,reason, andabort. This is the guard that will let CODE-477 delete the module on RN 0.87 / Expo SDK 58 without ceremony.Salvaged from the closed PR #309 (CODE-466, a duplicate of CODE-462): that branch shipped a second, weaker polyfill; only its test was worth keeping, and it is rewritten here against the surviving module.
Verification
pnpm test polyfills— 4 passed.pnpm test— 256 files passed, 3 skipped; 2,082 tests passed, 5 skipped.pnpm format:check,pnpm lint(0 errors),pnpm typecheck— all pass.AbortController.prototype.abortwrapper fails cases 2 and 3 only; forcing the guard always-true fails case 4 only. Both mutations were reverted.No device run: the change is test-only and the module it covers is unchanged.
Checklist
pnpm check:ciandpnpm testboth pass (pluscargo fmt/clippy/testfor Rust changes)WIRE_PROTOCOL_VERSIONis bumped (not applicable)