Skip to content

fix: default primp mobile requests to GaiResolver#81

Merged
ndonkoHenri merged 2 commits into
mainfrom
fix-primpt
Jun 18, 2026
Merged

fix: default primp mobile requests to GaiResolver#81
ndonkoHenri merged 2 commits into
mainfrom
fix-primpt

Conversation

@ndonkoHenri

Copy link
Copy Markdown

Fixes the primp mobile recipe so ordinary Android HTTPS requests no longer abort natively on first use.

Resolves flet-dev/flet#6603

Cause

primp is built with the hickory-dns feature enabled. In primp-reqwest, that makes Hickory the default DNS resolver when the caller does not provide one.

On Android, Hickory’s system DNS configuration path calls into ndk-context to access the Android Context. Flet loads primp as a Python extension through serious_python, and that Rust Android context is not initialized there. As a result, the first network request can abort the process with:

android context was not initialized

This happens below Python, so the app can crash before a Python exception can be raised or caught.

Fix

The recipe patch now changes the Python binding’s client builder behavior for mobile builds:

  • if the user passes an explicit dns_resolver, keep using that resolver
  • otherwise, on Android/iOS, install GaiResolver as the default resolver

This routes normal hostname resolution through the platform getaddrinfo path and avoids Hickory’s Android ndk-context system-DNS path. Explicit DoH/DoT/plain resolver support remains available.

The recipe test now performs a real HTTPS request and asserts that the request path either completes or raises a Python-level request error, rather than aborting the process.

@ndonkoHenri ndonkoHenri merged commit 2b3d4fc into main Jun 18, 2026
15 of 21 checks passed
@ndonkoHenri ndonkoHenri deleted the fix-primpt branch June 18, 2026 21:55
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.

bug: primp crashes with SIGABRT "android context was not initialized" on Android ARM64

1 participant