Conversation
jkmassel
force-pushed
the
jkmassel/silent-listener-failure
branch
from
September 15, 2026 20:11
a8f1040 to
355c9ad
Compare
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/663")Built from 37d598e |
jkmassel
force-pushed
the
jkmassel/silent-listener-failure
branch
3 times, most recently
from
September 15, 2026 20:37
8bbdac5 to
37d598e
Compare
jkmassel
changed the base branch from
test/media-mock-cleanup
to
fix/release-media-handling-on-teardown
September 15, 2026 20:37
jkmassel
force-pushed
the
jkmassel/silent-listener-failure
branch
from
September 15, 2026 22:03
37d598e to
41650f3
Compare
jkmassel
merged commit Sep 15, 2026
41650f3
into
fix/release-media-handling-on-teardown
0 of 2 checks passed
jkmassel
force-pushed
the
fix/release-media-handling-on-teardown
branch
from
September 15, 2026 22:03
50eefa7 to
7ee1945
Compare
3 tasks
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.
What?
HTTPServer.startnilsstateUpdateHandleron.readyand nothing replaces it, so a listener that failed after a successful bind left no trace anywhere — while the server went on reporting aportandtokenthat addressed a socket nobody was listening on.Replace the handler instead of clearing it, and log a post-start
.failedor.waiting. That's the whole change. No API change, no behaviour change.Why?
Mostly so an assumption becomes falsifiable.
We assume this never fires. There's no issue behind it, no report, no Sentry. The one hypothesis that was actually tested — TN2277 socket reclamation while suspended — was disproven on device: iPhone 15 Pro, 30.5 minutes suspended across four cycles with memory pressure from five foregrounded apps, listener still accepting TCP. The other candidates fail the bind instead, before
.ready, whichstart(...)already handles by throwing. Lockdown Mode was root-caused to CORS andOrigin: file://sanitization, not a listener kill.So this isn't a fix for an observed failure. It's the difference between "we assume it doesn't happen" and "we'd find out if we were wrong," for about ten lines.
Deliberately not doing
Not guaranteed. A state arriving in the gap between
.readybeing delivered and this assignment is still missed —.readyis delivered on the listener's queue and consumed off it, so for that stretch the start race's handler is still installed and whatever it yields goes into anAsyncStreamnothing reads any more. Closing that needs a re-read of the live state on the listener's queue plus one-shot reporting to stop the two observers doubling up. That's real complexity to never miss an event that has never happened; best-effort is the right trade for a diagnostic.Nothing acts on it. In particular the advertised endpoint is not withdrawn, because falling back to the WebView's default path is wrong in both modes:
tokenAuthMiddlewaresupplies theAuthorizationheader andallowUniversalAccessFromFileURLsexempts thefile://page from CORS, so a directPOST /wp/v2/medialands — silently skipping a hostMediaProcessorand putting GutenbergKit back on the network aMediaUploaderhost explicitly took it off ("with GutenbergKit out of the network entirely",MediaHandlers.swift:149-153). Nobody notices, because it worked.Left alone, the page keeps addressing the dead port and
nativeMediaUploadMiddlewaresurfaces afetch_errorwithout retrying. That's already the right outcome: an error the user can act on.Endpoint withdrawal does have a real trigger — a host calling
stopMediaHandling()deliberately — and that lives in #649, where it belongs..cancelledis not logged.stop()anddeinitare its only causes, so it's the ordinary teardown of every server and would be pure noise.How?
Captures only the port, so it holds neither the server nor the listener and cannot form a cycle with either.
Testing Instructions
There is nothing to reproduce by hand — that's the point of the PR — and nothing user-facing changes. The existing suites cover that replacing the handler doesn't disturb the start race:
swift test— 585GutenbergKitTests+ 396GutenbergKitHTTPTestsxcodebuild test— 589 + 396make lint-swiftcleanNo new tests. A log line with no observable behaviour doesn't warrant one, and asserting that a handler was installed would pin the implementation rather than anything real.
Related